fix downloading issue when chapter name contains special characters. Close #533

This commit is contained in:
2025-10-05 17:22:57 +08:00
parent ab786ed2ab
commit 8c625e212a
2 changed files with 38 additions and 3 deletions

View File

@@ -423,6 +423,7 @@ class LocalManager with ChangeNotifier {
if (comic.hasChapters) {
var cid =
ep is int ? comic.chapters!.ids.elementAt(ep - 1) : (ep as String);
cid = getChapterDirectoryName(cid);
directory = Directory(FilePath.join(directory.path, cid));
}
var files = <File>[];
@@ -600,7 +601,10 @@ class LocalManager with ChangeNotifier {
}
var shouldRemovedDirs = <Directory>[];
for (var chapter in chapters) {
var dir = Directory(FilePath.join(c.baseDir, chapter));
var dir = Directory(FilePath.join(
c.baseDir,
getChapterDirectoryName(chapter),
));
if (dir.existsSync()) {
shouldRemovedDirs.add(dir);
}
@@ -668,6 +672,21 @@ class LocalManager with ChangeNotifier {
}
});
}
static String getChapterDirectoryName(String name) {
var builder = StringBuffer();
for (var i = 0; i < name.length; i++) {
var char = name[i];
if (char == '/' || char == '\\' || char == ':' || char == '*' ||
char == '?'
|| char == '"' || char == '<' || char == '>' || char == '|') {
builder.write('_');
} else {
builder.write(char);
}
}
return builder.toString();
}
}
enum LocalSortType {