Skip to content

Commit 1acfc39

Browse files
committed
bugfix: avoid inbox renaming
Signed-off-by: 82Flex <82flex@gmail.com>
1 parent 27a9633 commit 1acfc39

File tree

5 files changed

+27
-4
lines changed

5 files changed

+27
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44

55
## Bug Fixes
66

7+
- Avoid in-box document renaming.
78
- Removed ads and prevented the app from crashing.

TrollFools/AppListView.swift

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ struct AppListView: View {
644644
guard url.isFileURL, url.pathExtension.lowercased() == "dylib" else {
645645
return
646646
}
647-
selectorOpenedURL = url
647+
selectorOpenedURL = preprocessURL(url)
648648
}
649649
}
650650

@@ -680,6 +680,28 @@ struct AppListView: View {
680680
}
681681
}
682682
}
683+
684+
private func preprocessURL(_ url: URL) -> URL {
685+
let isInbox = url.path.contains("/Documents/Inbox/")
686+
guard isInbox else {
687+
return url
688+
}
689+
let fileNameNoExt = url.deletingPathExtension().lastPathComponent
690+
let fileNameComps = fileNameNoExt.components(separatedBy: CharacterSet(charactersIn: "._- "))
691+
guard let lastComp = fileNameComps.last, fileNameComps.count > 1, lastComp.rangeOfCharacter(from: CharacterSet.decimalDigits.inverted) == nil else {
692+
return url
693+
}
694+
let newURL = url.deletingLastPathComponent()
695+
.appendingPathComponent(String(fileNameNoExt.prefix(fileNameNoExt.count - lastComp.count - 1)))
696+
.appendingPathExtension(url.pathExtension)
697+
do {
698+
try? FileManager.default.removeItem(at: newURL)
699+
try FileManager.default.copyItem(at: url, to: newURL)
700+
return newURL
701+
} catch {
702+
return url
703+
}
704+
}
683705
}
684706

685707
extension URL: Identifiable {

TrollFools/Version.Debug.xcconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
// https://help.apple.com/xcode/#/dev745c5c974
1010

1111
DEBUG_VERSION = 2.8
12-
DEBUG_BUILD_NUMBER = 202410202
12+
DEBUG_BUILD_NUMBER = 202410211

TrollFools/Version.xcconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
// https://help.apple.com/xcode/#/dev745c5c974
1010

1111
VERSION = 2.8
12-
BUILD_NUMBER = 14
12+
BUILD_NUMBER = 15

layout/DEBIAN/control

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: wiki.qaq.trollfools
22
Name: TrollFools
3-
Version: 2.8-14
3+
Version: 2.8-15
44
Section: Applications
55
Depends: firmware (>= 14.0)
66
Architecture: iphoneos-arm

0 commit comments

Comments
 (0)