fix: sync issues
This commit is contained in:
@@ -58,8 +58,14 @@ func (d *DiscoverMedias) RunE(from, to string) error {
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "get file md5: %s", video)
|
||||
}
|
||||
name := filepath.Base(video)[0:strings.LastIndex(filepath.Base(video), ".")]
|
||||
|
||||
if store.HashExists(md5) {
|
||||
if info, ok := store.HashExists(md5); ok {
|
||||
info.Name = name
|
||||
store.Update(info)
|
||||
if err := store.Save(to); err != nil {
|
||||
return errors.Wrapf(err, "save store: %s", to)
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -68,7 +74,7 @@ func (d *DiscoverMedias) RunE(from, to string) error {
|
||||
return errors.Wrapf(err, "process video: %s", video)
|
||||
}
|
||||
info.Hash = md5
|
||||
info.Name = filepath.Base(video)
|
||||
info.Name = name
|
||||
|
||||
store = store.Append(info)
|
||||
d.log.Infof("store: %+v", store)
|
||||
@@ -243,7 +249,7 @@ func (d *DiscoverMedias) runCleanup(to string) {
|
||||
}
|
||||
|
||||
for _, dir := range dirs {
|
||||
if store.HashExists(dir) {
|
||||
if _, ok := store.HashExists(dir); ok {
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user