mirror of https://github.com/perkeep/perkeep.git
twitter: revert 98a73d966d; it changed its imported root structure
I failed to catch that in review. Change-Id: Ie88298a2f34595b27c6f98af6f31b61a29ebac1b
This commit is contained in:
parent
8af06fa3ff
commit
0716bfdecf
|
@ -187,12 +187,6 @@ func (im *imp) Run(ctx *importer.RunContext) error {
|
|||
},
|
||||
}
|
||||
|
||||
rootNode := r.RootNode()
|
||||
if rootNode.Attr(nodeattr.Title) == "" {
|
||||
screenName := acctNode.Attr(importer.AcctAttrUserName)
|
||||
rootNode.SetAttr(nodeattr.Title, fmt.Sprintf("%s's Tweets", screenName))
|
||||
}
|
||||
|
||||
userID := acctNode.Attr(importer.AcctAttrUserID)
|
||||
if userID == "" {
|
||||
return errors.New("UserID hasn't been set by account setup.")
|
||||
|
@ -253,7 +247,11 @@ func (r *run) importTweets(userID string) error {
|
|||
maxId := ""
|
||||
continueRequests := true
|
||||
|
||||
tweetsNode := r.RootNode()
|
||||
tweetsNode, err := r.getTopLevelNode("tweets", "Tweets")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
numTweets := 0
|
||||
sawTweet := map[string]bool{}
|
||||
|
||||
|
@ -355,7 +353,10 @@ func tweetsFromZipFile(zf *zip.File) (tweets []*zipTweetItem, err error) {
|
|||
func (r *run) importTweetsFromZip(userID string, zr *zip.Reader) error {
|
||||
log.Printf("Processing zip file with %d files", len(zr.File))
|
||||
|
||||
tweetsNode := r.RootNode()
|
||||
tweetsNode, err := r.getTopLevelNode("tweets", "Tweets")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var (
|
||||
gate = syncutil.NewGate(tweetsAtOnce)
|
||||
|
@ -382,7 +383,7 @@ func (r *run) importTweetsFromZip(userID string, zr *zip.Reader) error {
|
|||
})
|
||||
}
|
||||
}
|
||||
err := grp.Err()
|
||||
err = grp.Err()
|
||||
log.Printf("zip import of tweets: %d total, err = %v", total, err)
|
||||
return err
|
||||
}
|
||||
|
@ -498,6 +499,17 @@ func (r *run) importTweet(parent *importer.Object, tweet tweetItem, viaAPI bool)
|
|||
return !changes, err
|
||||
}
|
||||
|
||||
func (r *run) getTopLevelNode(path string, title string) (*importer.Object, error) {
|
||||
tweets, err := r.RootNode().ChildPathObject(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := tweets.SetAttr("title", title); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return tweets, nil
|
||||
}
|
||||
|
||||
// TODO(mpl): move to an api.go when we it gets bigger.
|
||||
|
||||
type userInfo struct {
|
||||
|
|
Loading…
Reference in New Issue