mirror of
https://github.com/rumanzo/bt2qbt.git
synced 2024-11-22 02:12:39 +01:00
fix LRF RLF unicode symbols in names and file paths
add vscode in gitignore
This commit is contained in:
parent
0b305dd2f9
commit
ee7cb09a2e
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
.idea
|
||||
.vscode
|
||||
bt2qbt_v*
|
||||
vendors
|
@ -3,6 +3,11 @@ package transfer
|
||||
import (
|
||||
"crypto/sha1"
|
||||
"encoding/hex"
|
||||
"io"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/rumanzo/bt2qbt/internal/options"
|
||||
"github.com/rumanzo/bt2qbt/internal/replace"
|
||||
"github.com/rumanzo/bt2qbt/pkg/fileHelpers"
|
||||
@ -12,10 +17,6 @@ import (
|
||||
"github.com/rumanzo/bt2qbt/pkg/torrentStructures"
|
||||
"github.com/rumanzo/bt2qbt/pkg/utorrentStructs"
|
||||
"github.com/zeebo/bencode"
|
||||
"io"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
//goland:noinspection GoNameStartsWithPackageName
|
||||
@ -276,10 +277,19 @@ func (transfer *TransferStructure) HandleSavePaths() {
|
||||
var nameNormalized bool
|
||||
transfer.Fastresume.Name, nameNormalized = normalization.FullNormalize(transfer.TorrentFile.GetTorrentName())
|
||||
|
||||
if strings.ContainsAny(transfer.Fastresume.Name, "\u200e\u200f") {
|
||||
nameNormalized = true
|
||||
}
|
||||
|
||||
lastPathName := fileHelpers.Base(helpers.HandleCesu8(transfer.ResumeItem.Path))
|
||||
// if FileList contain only 1 file that means it is single file torrent
|
||||
if !transfer.TorrentFile.IsSingle() {
|
||||
fileList, filesNormalized := transfer.TorrentFile.GetFileList()
|
||||
for _, file := range fileList {
|
||||
if strings.ContainsAny(file, "\u200e\u200f") {
|
||||
filesNormalized = true
|
||||
}
|
||||
}
|
||||
|
||||
if lastPathName == transfer.Fastresume.Name && !filesNormalized && !nameNormalized {
|
||||
transfer.Fastresume.QBtContentLayout = "Original"
|
||||
|
@ -1,6 +1,10 @@
|
||||
package transfer
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
"github.com/r3labs/diff/v2"
|
||||
_ "github.com/r3labs/diff/v2"
|
||||
@ -8,8 +12,6 @@ import (
|
||||
"github.com/rumanzo/bt2qbt/pkg/qBittorrentStructures"
|
||||
"github.com/rumanzo/bt2qbt/pkg/torrentStructures"
|
||||
"github.com/rumanzo/bt2qbt/pkg/utorrentStructs"
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestTransferStructure_HandleSavePaths(t *testing.T) {
|
||||
@ -1684,6 +1686,37 @@ func TestTransferStructure_HandleSavePaths(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "047 Test torrent with multi file torrent with transfer to NoSubfolder RLF LRF symbols in torrent name and files",
|
||||
newTransferStructure: &TransferStructure{
|
||||
Fastresume: &qBittorrentStructures.QBittorrentFastresume{},
|
||||
ResumeItem: &utorrentStructs.ResumeItem{
|
||||
Path: "D:\\test files \u200e\u200f",
|
||||
},
|
||||
TorrentFile: &torrentStructures.Torrent{
|
||||
Info: &torrentStructures.TorrentInfo{
|
||||
Name: "test files \u200e\u200f",
|
||||
Files: []*torrentStructures.TorrentFile{
|
||||
&torrentStructures.TorrentFile{Path: []string{"file_with_emoji \u200e\u200f\xed\xa0\xbc\xed\xb6\x95.txt"}},
|
||||
&torrentStructures.TorrentFile{Path: []string{"testdir_with_emoji_and_space \u200e\u200f\xed\xa0\xbc\xed\xb6\x95 ", "file_with/slash.txt"}},
|
||||
},
|
||||
},
|
||||
},
|
||||
Opts: &options.Opts{PathSeparator: `\`},
|
||||
},
|
||||
expected: &TransferStructure{
|
||||
Fastresume: &qBittorrentStructures.QBittorrentFastresume{
|
||||
QbtSavePath: "D:/test files \u200e\u200f",
|
||||
SavePath: "D:\\test files \u200e\u200f",
|
||||
Name: "test files \u200e\u200f",
|
||||
QBtContentLayout: `NoSubfolder`,
|
||||
MappedFiles: []string{
|
||||
"file_with_emoji \u200e\u200f\xf0\x9f\x86\x95.txt",
|
||||
"testdir_with_emoji_and_space \u200e\u200f\xf0\x9f\x86\x95_\\file_with_slash.txt",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, testCase := range cases {
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
@ -1704,6 +1737,7 @@ func TestTransferStructure_HandleSavePaths(t *testing.T) {
|
||||
t.Fatalf("Unexpected error: opts isn't equal:\nGot: %#v\nExpect %#v\nDiff: %v\n", testCase.newTransferStructure.Fastresume, testCase.expected.Fastresume, spew.Sdump(changes))
|
||||
} else if equal && testCase.mustFail {
|
||||
t.Fatalf("Unexpected error: structures are equal, but they shouldn't\nGot: %v\n", spew.Sdump(testCase.newTransferStructure.Fastresume))
|
||||
fmt.Print("\u200e")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user