Don't double-download tweet contents
This commit is contained in:
parent
5d44186f91
commit
692d3de564
@ -174,7 +174,7 @@ func fetch_tweet_conversation(tweet_identifier string) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
die(fmt.Sprintf("Error saving tweet (id %d): %s", t.ID, err.Error()), false, 4)
|
die(fmt.Sprintf("Error saving tweet (id %d): %s", t.ID, err.Error()), false, 4)
|
||||||
}
|
}
|
||||||
err = profile.DownloadTweetContentFor(&t)
|
_, err = profile.DownloadTweetContentIfNeeded(&t)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
die("Error getting tweet content: " + err.Error(), false, 11)
|
die("Error getting tweet content: " + err.Error(), false, 11)
|
||||||
}
|
}
|
||||||
@ -217,7 +217,7 @@ func fetch_user_feed(handle string, how_many int) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
die("Error saving tweet: " + err.Error(), false, 4)
|
die("Error saving tweet: " + err.Error(), false, 4)
|
||||||
}
|
}
|
||||||
err = profile.DownloadTweetContentFor(&t)
|
_, err = profile.DownloadTweetContentIfNeeded(&t)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
die("Error getting tweet content: " + err.Error(), false, 11)
|
die("Error getting tweet content: " + err.Error(), false, 11)
|
||||||
}
|
}
|
||||||
@ -286,7 +286,7 @@ func search(query string) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
die("Error saving tweet: " + err.Error(), false, 4)
|
die("Error saving tweet: " + err.Error(), false, 4)
|
||||||
}
|
}
|
||||||
err = profile.DownloadTweetContentFor(&t)
|
_, err = profile.DownloadTweetContentIfNeeded(&t)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
die("Error getting tweet content: " + err.Error(), false, 11)
|
die("Error getting tweet content: " + err.Error(), false, 11)
|
||||||
}
|
}
|
||||||
|
@ -174,5 +174,17 @@ func (p Profile) DownloadUserContentIfNeeded(u *scraper.User) (bool, error) {
|
|||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
return true, p.DownloadUserContentFor(u)
|
return true, p.DownloadUserContentFor(u)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Download a Tweet's content, if needed.
|
||||||
|
*
|
||||||
|
* Returns whether anything was downloaded or not.
|
||||||
|
*/
|
||||||
|
func (p Profile) DownloadTweetContentIfNeeded(t *scraper.Tweet) (bool, error) {
|
||||||
|
if !p.CheckTweetContentDownloadNeeded(*t) {
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
return true, p.DownloadTweetContentFor(t)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user