|
|
@ -445,8 +445,20 @@ func markDone(dldir, location string) error {
|
|
|
|
if *verboseFlag {
|
|
|
|
if *verboseFlag {
|
|
|
|
log.Printf("Marking %v as done", location)
|
|
|
|
log.Printf("Marking %v as done", location)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// TODO(mpl): back up .lastdone before overwriting it, in case writing it fails.
|
|
|
|
oldPath := filepath.Join(dldir, ".lastdone")
|
|
|
|
if err := ioutil.WriteFile(filepath.Join(dldir, ".lastdone"), []byte(location), 0600); err != nil {
|
|
|
|
newPath := oldPath + ".bak"
|
|
|
|
|
|
|
|
if err := os.Rename(oldPath, newPath); err != nil {
|
|
|
|
|
|
|
|
if !os.IsNotExist(err) {
|
|
|
|
|
|
|
|
return err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := ioutil.WriteFile(oldPath, []byte(location), 0600); err != nil {
|
|
|
|
|
|
|
|
// restore from backup
|
|
|
|
|
|
|
|
if err := os.Rename(newPath, oldPath); err != nil {
|
|
|
|
|
|
|
|
if !os.IsNotExist(err) {
|
|
|
|
|
|
|
|
return err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
@ -519,6 +531,9 @@ func (s *Session) download(ctx context.Context, location string) (string, error)
|
|
|
|
if v.Name() == ".lastdone" {
|
|
|
|
if v.Name() == ".lastdone" {
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if v.Name() == ".lastdone.bak" {
|
|
|
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
}
|
|
|
|
fileEntries = append(fileEntries, v)
|
|
|
|
fileEntries = append(fileEntries, v)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if len(fileEntries) < 1 {
|
|
|
|
if len(fileEntries) < 1 {
|
|
|
|