Skip to content

Commit

Permalink
bugfix: avoid inbox renaming
Browse files Browse the repository at this point in the history
Signed-off-by: 82Flex <[email protected]>
  • Loading branch information
Lessica committed Oct 20, 2024
1 parent 27a9633 commit 1acfc39
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@

## Bug Fixes

- Avoid in-box document renaming.
- Removed ads and prevented the app from crashing.
24 changes: 23 additions & 1 deletion TrollFools/AppListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ struct AppListView: View {
guard url.isFileURL, url.pathExtension.lowercased() == "dylib" else {
return
}
selectorOpenedURL = url
selectorOpenedURL = preprocessURL(url)
}
}

Expand Down Expand Up @@ -680,6 +680,28 @@ struct AppListView: View {
}
}
}

private func preprocessURL(_ url: URL) -> URL {
let isInbox = url.path.contains("/Documents/Inbox/")
guard isInbox else {
return url
}
let fileNameNoExt = url.deletingPathExtension().lastPathComponent
let fileNameComps = fileNameNoExt.components(separatedBy: CharacterSet(charactersIn: "._- "))
guard let lastComp = fileNameComps.last, fileNameComps.count > 1, lastComp.rangeOfCharacter(from: CharacterSet.decimalDigits.inverted) == nil else {
return url
}
let newURL = url.deletingLastPathComponent()
.appendingPathComponent(String(fileNameNoExt.prefix(fileNameNoExt.count - lastComp.count - 1)))
.appendingPathExtension(url.pathExtension)
do {
try? FileManager.default.removeItem(at: newURL)
try FileManager.default.copyItem(at: url, to: newURL)
return newURL
} catch {
return url
}
}
}

extension URL: Identifiable {
Expand Down
2 changes: 1 addition & 1 deletion TrollFools/Version.Debug.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
// https://help.apple.com/xcode/#/dev745c5c974

DEBUG_VERSION = 2.8
DEBUG_BUILD_NUMBER = 202410202
DEBUG_BUILD_NUMBER = 202410211
2 changes: 1 addition & 1 deletion TrollFools/Version.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
// https://help.apple.com/xcode/#/dev745c5c974

VERSION = 2.8
BUILD_NUMBER = 14
BUILD_NUMBER = 15
2 changes: 1 addition & 1 deletion layout/DEBIAN/control
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: wiki.qaq.trollfools
Name: TrollFools
Version: 2.8-14
Version: 2.8-15
Section: Applications
Depends: firmware (>= 14.0)
Architecture: iphoneos-arm
Expand Down

0 comments on commit 1acfc39

Please sign in to comment.