Fix nosafe mode

This commit is contained in:
2024-08-29 11:50:09 +02:00
parent 0c12f1f1b6
commit 2057c821d2

View File

@@ -66,9 +66,12 @@ func main() {
return
}
filedir := filepath.Dir(file)
filename := filepath.Base(file)
if *nosafe {
if !*nosafe {
bckp := filename + ".bak"
bckp = filepath.Join(filedir, bckp)
err := os.Link(file, bckp)
if err != nil {
Error.Printf("Failed to backup file: %v", err)
@@ -97,6 +100,7 @@ func main() {
filehandle.Close()
newfile := strings.Replace(filename, ext, *to, 1)
newfile = filepath.Join(filedir, newfile)
log.Printf("Encoding %s to %s", file, newfile)
buf, err := coder.Encode(image, *quality)