mirror of
https://github.com/rumanzo/bt2qbt.git
synced 2024-11-22 10:22:38 +01:00
Fix removing path separator from utorrent path field
This commit is contained in:
parent
f421df467c
commit
f7c5d00b94
10
bt2qbt.go
10
bt2qbt.go
@ -22,6 +22,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
"unicode/utf8"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Flags struct {
|
type Flags struct {
|
||||||
@ -203,11 +204,16 @@ func logic(key string, value map[string]interface{}, flags *Flags, chans *Channe
|
|||||||
} else {
|
} else {
|
||||||
newstructure.HasFiles = false
|
newstructure.HasFiles = false
|
||||||
}
|
}
|
||||||
if value["path"].(string)[len(value["path"].(string))-1] == os.PathSeparator {
|
|
||||||
newstructure.Path = value["path"].(string)[:len(value["path"].(string))-1]
|
// remove separator from end
|
||||||
|
lastRune, lastRuneSize := utf8.DecodeLastRuneInString(value["path"].(string))
|
||||||
|
separatorRunes := []rune("/\\")
|
||||||
|
if lastRune == separatorRunes[0] || lastRune == separatorRunes[1] {
|
||||||
|
newstructure.Path = value["path"].(string)[:len(value["path"].(string))-lastRuneSize]
|
||||||
} else {
|
} else {
|
||||||
newstructure.Path = value["path"].(string)
|
newstructure.Path = value["path"].(string)
|
||||||
}
|
}
|
||||||
|
|
||||||
// if torrent name was renamed, add modified name
|
// if torrent name was renamed, add modified name
|
||||||
if value["caption"] != nil {
|
if value["caption"] != nil {
|
||||||
newstructure.QbtName = value["caption"].(string)
|
newstructure.QbtName = value["caption"].(string)
|
||||||
|
Loading…
Reference in New Issue
Block a user