Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions Sources/Shared/Toolkit/Archive/ExplodedArchive.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ final class ExplodedArchive: Archive, Loggable {
}

private init(file: FileURL) {
root = file
root = file.resolvingSymlinks()
}

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

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

private func entryURL(fromPath path: String) -> FileURL? {
let url = root.appendingPath(path, isDirectory: false)
let url = root.appendingPath(path, isDirectory: false).resolvingSymlinks()
guard
root.isParent(of: url)
else {
Expand Down
6 changes: 6 additions & 0 deletions Sources/Shared/Toolkit/URL/Absolute URL/FileURL.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ public struct FileURL: AbsoluteURL, Hashable {
url.lastPathComponent
}

/// Returns new `FileURL` with symlinks resolved
// FIXME: Async
public func resolvingSymlinks() -> Self {
Self(url: url.resolvingSymlinksInPath())!
}

/// Returns whether the given `url` is `self` or one of its descendants.
public func isParent(of other: FileURL) -> Bool {
path == other.path || other.path.hasPrefix(path.addingSuffix("/"))
Expand Down