mirror of
https://github.com/cgzirim/seek-tune.git
synced 2025-12-17 08:54:19 +00:00
Move songs in wav format to songs dir
This commit is contained in:
parent
a439b87af8
commit
aeb72e8ace
1 changed files with 12 additions and 4 deletions
|
|
@ -238,7 +238,6 @@ func erase(songsDir string) {
|
||||||
fmt.Println("Erase complete")
|
fmt.Println("Erase complete")
|
||||||
}
|
}
|
||||||
|
|
||||||
// index processes the path, whether it's a directory or a single file.
|
|
||||||
func save(path string, force bool) {
|
func save(path string, force bool) {
|
||||||
fileInfo, err := os.Stat(path)
|
fileInfo, err := os.Stat(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -256,7 +255,7 @@ func save(path string, force bool) {
|
||||||
if !info.IsDir() {
|
if !info.IsDir() {
|
||||||
err := saveSong(filePath, force)
|
err := saveSong(filePath, force)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Error indexing song (%v): %v\n", filePath, err)
|
fmt.Printf("Error saving song (%v): %v\n", filePath, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
@ -265,10 +264,9 @@ func save(path string, force bool) {
|
||||||
fmt.Printf("Error walking the directory %v: %v\n", path, err)
|
fmt.Printf("Error walking the directory %v: %v\n", path, err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// If it's a file, process it directly
|
|
||||||
err := saveSong(path, force)
|
err := saveSong(path, force)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Error indexing song (%v): %v\n", path, err)
|
fmt.Printf("Error saving song (%v): %v\n", path, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -309,5 +307,15 @@ func saveSong(filePath string, force bool) error {
|
||||||
return fmt.Errorf("failed to process or save song: %v", err)
|
return fmt.Errorf("failed to process or save song: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Move song in wav format to songs directory
|
||||||
|
fileName := strings.TrimSuffix(filepath.Base(filePath), filepath.Ext(filePath))
|
||||||
|
wavFile := fileName + ".wav"
|
||||||
|
sourcePath := filepath.Join(filepath.Dir(filePath), wavFile)
|
||||||
|
newFilePath := filepath.Join(SONGS_DIR, wavFile)
|
||||||
|
err = os.Rename(sourcePath, newFilePath)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to rename temporary file to output file: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue