Skip to content

Commit 7c04a98

Browse files
authored
Fix permissions when importing a publication (#343)
1 parent f843069 commit 7c04a98

File tree

3 files changed

+10
-14
lines changed

3 files changed

+10
-14
lines changed

TestApp/Sources/Info.plist

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,9 @@
228228
<key>CFBundlePackageType</key>
229229
<string>APPL</string>
230230
<key>CFBundleShortVersionString</key>
231-
<string>2.2.2</string>
231+
<string>2.6.0</string>
232232
<key>CFBundleVersion</key>
233-
<string>2.2.2</string>
233+
<string>2.6.0</string>
234234
<key>LSRequiresIPhoneOS</key>
235235
<true/>
236236
<key>LSSupportsOpeningDocumentsInPlace</key>
@@ -243,7 +243,6 @@
243243
<key>UIBackgroundModes</key>
244244
<array>
245245
<string>audio</string>
246-
<string>processing</string>
247246
</array>
248247
<key>UIFileSharingEnabled</key>
249248
<true/>

TestApp/Sources/Library/LibraryService.swift

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,14 @@ final class LibraryService: Loggable {
103103
/// document.
104104
@discardableResult
105105
func importPublication(from sourceURL: URL, sender: UIViewController, progress: @escaping (Double) -> Void = { _ in }) async throws -> Book {
106+
// Necessary to read URL exported from the Files app, for example.
107+
let shouldRelinquishAccess = sourceURL.startAccessingSecurityScopedResource()
108+
defer {
109+
if shouldRelinquishAccess {
110+
sourceURL.stopAccessingSecurityScopedResource()
111+
}
112+
}
113+
106114
var url = try await downloadIfNeeded(sourceURL, progress: progress)
107115
url = try await fulfillIfNeeded(url)
108116
let (pub, mediaType) = try await openPublication(at: url, allowUserInteraction: false, sender: sender)
@@ -144,13 +152,6 @@ final class LibraryService: Loggable {
144152
/// Moves the given `sourceURL` to the user Documents/ directory.
145153
private func moveToDocuments(from source: URL, title: String, mediaType: MediaType) throws -> URL {
146154
let destination = Paths.makeDocumentURL(title: title, mediaType: mediaType)
147-
// Necessary to read URL exported from the Files app, for example.
148-
let shouldRelinquishAccess = source.startAccessingSecurityScopedResource()
149-
defer {
150-
if shouldRelinquishAccess {
151-
source.stopAccessingSecurityScopedResource()
152-
}
153-
}
154155

155156
do {
156157
// If the source file is part of the app folder, we can move it. Otherwise we make a

TestApp/Sources/Reader/Audiobook/AudiobookModule.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@ final class AudiobookModule: ReaderFormatModule {
2929
bookmarks: BookmarkRepository,
3030
highlights: HighlightRepository
3131
) async throws -> UIViewController {
32-
guard publication.metadata.identifier != nil else {
33-
throw ReaderError.epubNotValid
34-
}
35-
3632
let viewController = AudiobookViewController(
3733
publication: publication,
3834
locator: locator,

0 commit comments

Comments
 (0)