Skip to content

Commit cc6c1fa

Browse files
committed
Handle URLs with aliases in ExplodedArchive
Fixes #434
1 parent 434e47b commit cc6c1fa

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

Sources/Shared/Toolkit/Archive/ExplodedArchive.swift

+2-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ final class ExplodedArchive: Archive, Loggable {
2323
}
2424

2525
private init(file: FileURL) {
26-
root = file
26+
root = file.resolvingSymlinks()
2727
}
2828

2929
lazy var entries: [ArchiveEntry] = {
@@ -52,7 +52,6 @@ final class ExplodedArchive: Archive, Loggable {
5252

5353
private func makeEntry(at url: FileURL) -> ArchiveEntry? {
5454
guard
55-
root.isParent(of: url),
5655
let values = try? url.url.resourceValues(forKeys: [.fileSizeKey, .isDirectoryKey]),
5756
let length = values.fileSize,
5857
values.isDirectory != true
@@ -68,7 +67,7 @@ final class ExplodedArchive: Archive, Loggable {
6867
}
6968

7069
private func entryURL(fromPath path: String) -> FileURL? {
71-
let url = root.appendingPath(path, isDirectory: false)
70+
let url = root.appendingPath(path, isDirectory: false).resolvingSymlinks()
7271
guard
7372
root.isParent(of: url)
7473
else {

Sources/Shared/Toolkit/URL/Absolute URL/FileURL.swift

+6
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ public struct FileURL: AbsoluteURL, Hashable {
4444
url.lastPathComponent
4545
}
4646

47+
/// Returns new `FileURL` with symlinks resolved
48+
// FIXME: Async
49+
public func resolvingSymlinks() -> Self {
50+
Self(url: url.resolvingSymlinksInPath())!
51+
}
52+
4753
/// Returns whether the given `url` is `self` or one of its descendants.
4854
public func isParent(of other: FileURL) -> Bool {
4955
path == other.path || other.path.hasPrefix(path.addingSuffix("/"))

0 commit comments

Comments
 (0)