mirror of
https://github.com/rumanzo/bt2qbt.git
synced 2024-11-08 20:02:30 +01:00
Merge pull request #17 from rumanzo/mappedfilesreplace
Replace MappedFiles separators if defined
This commit is contained in:
commit
885c0ff94c
@ -278,7 +278,6 @@ func main() {
|
||||
flags.QBitDir = usr.HomeDir + sep + "Library" + sep + "Application Support" + sep + "QBittorrent" + sep + "BT_backup" + sep
|
||||
}
|
||||
|
||||
_, err := goflags.Parse(&flags)
|
||||
if _, err := goflags.Parse(&flags); err != nil { // https://godoc.org/github.com/jessevdk/go-flags#ErrorType
|
||||
if flagsErr, ok := err.(*goflags.Error); ok && flagsErr.Type == goflags.ErrHelp {
|
||||
os.Exit(0)
|
||||
|
@ -273,15 +273,22 @@ func (newstructure *NewTorrentStructure) FillSavePaths() {
|
||||
for _, pattern := range newstructure.Replace {
|
||||
newstructure.QbtSavePath = strings.ReplaceAll(newstructure.QbtSavePath, pattern.From, pattern.To)
|
||||
}
|
||||
var oldsep string
|
||||
switch newstructure.Separator {
|
||||
case "\\":
|
||||
newstructure.QbtSavePath = strings.ReplaceAll(newstructure.QbtSavePath, "/", newstructure.Separator)
|
||||
oldsep = "/"
|
||||
case "/":
|
||||
newstructure.QbtSavePath = strings.ReplaceAll(newstructure.QbtSavePath, "\\", newstructure.Separator)
|
||||
|
||||
oldsep = "\\"
|
||||
}
|
||||
|
||||
newstructure.QbtSavePath = strings.ReplaceAll(newstructure.QbtSavePath, oldsep, newstructure.Separator)
|
||||
newstructure.SavePath = strings.ReplaceAll(newstructure.QbtSavePath, "\\", "/")
|
||||
|
||||
for num, entry := range newstructure.MappedFiles {
|
||||
newentry := strings.ReplaceAll(entry, oldsep, newstructure.Separator)
|
||||
if entry != newentry {
|
||||
newstructure.MappedFiles[num] = newentry
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func fmtime(path string) (mtime int64) {
|
||||
|
Loading…
Reference in New Issue
Block a user