Skip to content

Commit

Permalink
audioc: processBundle handles []metadata.Metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
rolyatsats committed Dec 9, 2019
1 parent 47b1add commit 3a9f873
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions audioc/folder.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ func (a *audioc) processBundle(indexes []int) error {
}
}

// process folder via threads returning the resulting dir
// process folder via threads returning the resulting metadata slice
// calls a.processFile() for each index
dir, err := a.processThreaded(indexes)
d, err := a.processThreaded(indexes)
if err != nil {
return err
}
Expand All @@ -58,16 +58,18 @@ func (a *audioc) processBundle(indexes []int) error {
// explicitly remove workdir (before folder is renamed)
os.RemoveAll(a.Workdir)

fullResultD := filepath.Dir(filepath.Join(a.DirEntry, d[0].Resultpath))

// if not same dir, rename directory to target dir
if fullDir != dir {
_, err = fsutil.MergeFolder(fullDir, dir, mergeFolderFunc)
if fullDir != fullResultD {
_, err = fsutil.MergeFolder(fullDir, fullResultD, mergeFolderFunc)
if err != nil {
return err
}
}

// remove parent folder if no longer contains audio files
// TODO add check to ensure not removing any of DirEntry
// TODO fsutil.FilesAudio(parentDir) breaks when parentDir is a symlink
parentDir := filepath.Dir(fullDir)
if len(fsutil.FilesAudio(parentDir)) == 0 {
err = os.RemoveAll(parentDir)
Expand Down

0 comments on commit 3a9f873

Please sign in to comment.