Fix nosafe mode
This commit is contained in:
6
main.go
6
main.go
@@ -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)
|
||||
|
Reference in New Issue
Block a user