Merge branch 'main' of https://github.com/Ranchero-Software/NetNewsWire
This commit is contained in:
commit
c5388b8d0d
@ -58,7 +58,7 @@ public class ArticleThemeDownloader {
|
|||||||
let unzipDirectory = URL(fileURLWithPath: location.path.replacingOccurrences(of: ".zip", with: ""))
|
let unzipDirectory = URL(fileURLWithPath: location.path.replacingOccurrences(of: ".zip", with: ""))
|
||||||
try Zip.unzipFile(location, destination: unzipDirectory, overwrite: true, password: nil, progress: nil, fileOutputHandler: nil) // Unzips to folder in Application Support/NetNewsWire/Downloads
|
try Zip.unzipFile(location, destination: unzipDirectory, overwrite: true, password: nil, progress: nil, fileOutputHandler: nil) // Unzips to folder in Application Support/NetNewsWire/Downloads
|
||||||
try FileManager.default.removeItem(at: location) // Delete zip in Cache
|
try FileManager.default.removeItem(at: location) // Delete zip in Cache
|
||||||
let themeFilePath = FileManager.default.filenames(inFolder: unzipDirectory.path)?.first(where: { $0.contains(".nnwtheme") })
|
let themeFilePath = findThemeFile(in: unzipDirectory.path)
|
||||||
if themeFilePath == nil {
|
if themeFilePath == nil {
|
||||||
throw ArticleThemeDownloaderError.noThemeFile
|
throw ArticleThemeDownloaderError.noThemeFile
|
||||||
}
|
}
|
||||||
@ -69,6 +69,22 @@ public class ArticleThemeDownloader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// Performs a deep search of the unzipped direcotry to find the theme file.
|
||||||
|
/// - Parameter searchPath: directory to search
|
||||||
|
/// - Returns: optional `String`
|
||||||
|
private func findThemeFile(in searchPath: String) -> String? {
|
||||||
|
if let directoryContents = FileManager.default.enumerator(atPath: searchPath) {
|
||||||
|
while let file = directoryContents.nextObject() as? String {
|
||||||
|
if file.hasSuffix(".nnwtheme") {
|
||||||
|
return file
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
/// The download directory used by the theme downloader: `Application Suppport/NetNewsWire/Downloads`
|
/// The download directory used by the theme downloader: `Application Suppport/NetNewsWire/Downloads`
|
||||||
/// - Returns: `URL`
|
/// - Returns: `URL`
|
||||||
private func downloadDirectory() -> URL {
|
private func downloadDirectory() -> URL {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user