This commit is contained in:
milarin 2023-01-15 14:10:27 +01:00
parent a4f5b7887b
commit 411ffccb28

View File

@ -77,39 +77,55 @@ func OrganizeAnimeEpisode(b *strings.Builder, parsedFile *model.ParsedFile) erro
return err
}
b.WriteString("1")
if err := os.Chown(filepath.Dir(newFile), Uid, Gid); err != nil {
return err
}
b.WriteString("2")
if _, err := os.Stat(newFile); !errors.Is(err, os.ErrNotExist) {
return err
}
b.WriteString("3")
inputFile, err := os.Open(oldFile)
if err != nil {
return err
}
defer inputFile.Close()
b.WriteString("4")
outputFile, err := os.Create(newFile)
if err != nil {
return err
}
defer outputFile.Close()
b.WriteString("5")
if err := os.Chown(newFile, Uid, Gid); err != nil {
return err
}
b.WriteString("6")
written, err := io.Copy(outputFile, inputFile)
if err != nil {
return err
}
b.WriteString("7 " + FormatBytes(written))
if err = os.Remove(oldFile); err != nil {
return err
}
b.WriteString("8")
if err = os.Remove(lockFile); err != nil {
return err
}