From 249dc6421d30d6e8e8e25ca6084756bb015bab79 Mon Sep 17 00:00:00 2001 From: Lu Chang Date: Sun, 11 Dec 2022 14:25:34 +0800 Subject: [PATCH] release: 0.3.4 add: print accurate log when the files are lost or permission denied. --- main.go | 27 ++++++++++++++++++++++----- version.txt | 2 +- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/main.go b/main.go index b9ca558..223afbe 100644 --- a/main.go +++ b/main.go @@ -45,7 +45,7 @@ var ( debug bool = false ) -var version string = "0.3.3" +var version string = "0.3.4" type hashsPair struct { hash2Torrent map[string]qbt.BasicTorrent @@ -378,14 +378,31 @@ func exportTorrentFiles(hashs *hashsPair, filter *filterOptions, appendTagName s curFilename = strings.ReplaceAll(curFilename, "", toSafeFolderName(torrent.State)) curFilename = strings.ReplaceAll(curFilename, "", toSafeFolderName(torrent.Name)) _, err = os.Stat("BT_backup/" + hash + ".torrent") - if err != nil { - fmt.Println("Error: ", torrent.Name, "(", torrent.Hash, ") Not Found in BT_backup") + if err != nil && os.IsNotExist(err) { + fmt.Println("Error: ", torrent.Name, "(", torrent.Hash, ".torrent) Not Found in BT_backup") + errorCount++ + continue + } else if err != nil && os.IsPermission(err) { + fmt.Println("Error: No permission to access BT_backup/", torrent.Hash, ".torrent for ", torrent.Name) + errorCount++ + continue + } else if err != nil { + fmt.Println("Error: ", torrent.Name, "(", torrent.Hash, ".", "torrent) ", err.Error()) errorCount++ continue } + _, err = os.Stat("BT_backup/" + hash + ".fastresume") - if err != nil { - fmt.Println("Error: ", torrent.Name, "(", torrent.Hash, ") .fastresume Not Found in BT_backup") + if err != nil && os.IsNotExist(err) { + fmt.Println("Error: ", torrent.Name, "(", torrent.Hash, ".fastresume) Not Found in BT_backup") + errorCount++ + continue + } else if err != nil && os.IsPermission(err) { + fmt.Println("Error: No permission to access BT_backup/", torrent.Hash, ".fastresume for ", torrent.Name) + errorCount++ + continue + } else if err != nil { + fmt.Println("Error: ", torrent.Name, "(", torrent.Hash, ".", "fastresume) ", err.Error()) errorCount++ continue } diff --git a/version.txt b/version.txt index 1c09c74..42045ac 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -0.3.3 +0.3.4