Comments (9)
I would expect maybe permission issues to get the children of the directory URLs? But hard to say without debugging. Do you have an error message?
from swift-toolkit.
I don't see any error message, just the .unsupportedFormat
failure from Streamer.open
. The contents of the directory are found when I try in a breakpoint. Could you direct me to the part of the codebase which is failing to create a Publication
from the directory so I can dig into what's happening there?
from swift-toolkit.
You could take a look at ExplodedArchive
and see if it contains the expected entries.
from swift-toolkit.
Thanks for the tip! That was what I needed to figure it out.
This is failing due to an insane behavior of App Group URLs on MacOS combined with what I think may be an unnecessary behavior in Readium.
The insane behavior is that there are apparently two types of App Group URLs. When one calls FileManager.containerURL(forSecurityApplicationGroupIdentifier: APP_GROUP_IDENTIFIER)
, it generates a URL pointing to ~/Library/GroupContainersAlias/APP_GROUP_IDENTIFIER/
. However, that GroupContainersAlias
component is, unsurprisingly, an alias. The true directory is ~/Library/Group Containers/APP_GROUP_IDENTIFIER/
. Even weirder, I haven't been able to find any documentation, even unofficially, on this specific behavior. When listing the contents of a directory in an app group container, the results have aliases resolved. For example, the contents of ~/Library/GroupContainersAlias/APP_GROUP_IDENTIFIER/Assets/ID/Publication/
look like ~/Library/Group Containers/APP_GROUP_IDENTIFIER/Assets/ID/Publication/file.mp3
.
The possibly unnecessary Readium behavior is that ExplodedArchive
checks that each entry is a child of the root directory when making entries. I think this may be unnecessary because makeEntry
is a private function that is only called by the lazy entries
var when iterating over the contents of the root directory, so I think every time makeEntry
is called the URL passed in must be a child of the root URL. Commenting out root.isParent(of: url)
from the guard
in makeEntry
fixes the failure I am seeing. Regardless of this, perhaps it's worth reconsidering the functionality of FileURL.isParent
. Checking the path prefix to determine parentage is not accurate without first resolving aliases in each component of both URLs. If you'd like, I'll contribute either or both of these changes.
from swift-toolkit.
The possibly unnecessary Readium behavior is that ExplodedArchive checks that each entry is a child of the root directory when making entries. I think this may be unnecessary because makeEntry is a private function that is only called by the lazy entries var when iterating over the contents of the root directory
Agreed, it looks unnecessary. Feel free to remove the check if that helps with this issue.
It is useful when getting an entry though, to make sure we don't request for example ../../../private/file
, so fixing FileURL.isParent
might be useful as well. I think you could use URL.resolvingSymlinksInPath()
for that. As this will query the filesystem, could you add a FIXME comment to make sure we change FileURL.isParent
to async later? Thanks!
from swift-toolkit.
URL.resolvingSymlinksInPath()
would work and is what I used in my project to work around this issue. Would it make sense to add that in FileURL.init
instead of .isParent
since there is already normalization occurring in .init
, that normalization is relevant for other functionality as well, and it would prevent symlink resolution from needing to be done repeatedly?
- let url = url.standardizedFileURL
+ let url = url.standardizedFileURL.resolvingSymlinksInPath()
from swift-toolkit.
I'd prefer to keep it outside the constructor because it will reach the file system and should be asynchronous.
In fact, maybe it would be better to keep isParent
as is, and add instead a fileURL.resolvingSymlinks() async -> FileURL
to be called before isParent()
.
from swift-toolkit.
Sure, I can do that if you want. I just thought that URL.standardizedFileURL
(already called in init
) might need to touch the file system to resolve "."
and ".."
. Does it not do that?
Anyway, I'll proceed with the separate async version you described unless you say otherwise.
from swift-toolkit.
AFAIK it doesn't need to access the file system to resolve .
and ..
, as it's purely syntactic. For example a/b/../c
-> a/c
.
from swift-toolkit.
Related Issues (20)
- Extracting `t` fragment from `Locator` HOT 1
- Larger Text Display Zoom on iPhone: Navigation bar pushes text HOT 3
- Pinning the font size (for <p>, <li>, <div>, etc) HOT 1
- Logger doesn't log above min severity level
- AudioNavigator.seek cannot cross previous resource boundary HOT 10
- When a DRM key error occurs while opening an EPUB, navigator is stuck in loading state HOT 10
- Errors while loading a Resource in GCDHTTPServer are not bubbled up HOT 5
- 'asSQL' is inaccessible due to 'internal' protection level HOT 2
- Name collision caused by GCDWebServer dependency HOT 5
- Error"Error initializing db." HOT 13
- Nondeterministic loading issue with `EPUBNavigatorViewController` HOT 2
- [Feature] Add support for new LCP Profiles
- Logic behind the selected text information for remote server HOT 2
- Pagination after increasing the font size HOT 4
- [Bug] EditingActions like Define Lookup are not shown. HOT 1
- [develop] Locator href for exploded archive audiobook incorrectly starts with leading slash HOT 2
- [Bug] Search Result Chapter Title HOT 6
- lcpl file which is pub format can't be open by publication.metadata.identifier is nil HOT 6
- `Navigator.go` results in misaligned view HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swift-toolkit.