diff --git a/Aerial/Source/Controllers/PWC Tabs/PWC+Cache.swift b/Aerial/Source/Controllers/PWC Tabs/PWC+Cache.swift
index a55d8cf4..cdd9a70f 100644
--- a/Aerial/Source/Controllers/PWC Tabs/PWC+Cache.swift
+++ b/Aerial/Source/Controllers/PWC Tabs/PWC+Cache.swift
@@ -31,6 +31,7 @@ extension PreferencesWindowController {
cacheLocation.url = nil
}
}
+
func updateCacheSize() {
// get your directory url
let documentsDirectoryURL = URL(fileURLWithPath: VideoCache.cacheDirectory!)
@@ -75,27 +76,40 @@ extension PreferencesWindowController {
}
@IBAction func userSetCacheLocation(_ button: NSButton?) {
- let openPanel = NSOpenPanel()
-
- openPanel.canChooseDirectories = true
- openPanel.canChooseFiles = false
- openPanel.canCreateDirectories = true
- openPanel.allowsMultipleSelection = false
- openPanel.title = "Choose Aerial Cache Directory"
- openPanel.prompt = "Choose"
- openPanel.directoryURL = cacheLocation.url
-
- openPanel.begin { result in
- guard result.rawValue == NSFileHandlingPanelOKButton, !openPanel.urls.isEmpty else {
- return
- }
+ if #available(OSX 10.15, *) {
+ cacheFolderTextField.stringValue = VideoCache.cacheDirectory!
+ changeCacheFolderPanel.makeKeyAndOrderFront(self)
+ } else {
+ let openPanel = NSOpenPanel()
+
+ openPanel.canChooseDirectories = true
+ openPanel.canChooseFiles = false
+ openPanel.canCreateDirectories = true
+ openPanel.allowsMultipleSelection = false
+ openPanel.title = "Choose Aerial Cache Directory"
+ openPanel.prompt = "Choose"
+ openPanel.directoryURL = cacheLocation.url
- let cacheDirectory = openPanel.urls[0]
- self.preferences.customCacheDirectory = cacheDirectory.path
- self.cacheLocation.url = cacheDirectory
+ openPanel.begin { result in
+ guard result.rawValue == NSFileHandlingPanelOKButton, !openPanel.urls.isEmpty else {
+ return
+ }
+
+ let cacheDirectory = openPanel.urls[0]
+ self.preferences.customCacheDirectory = cacheDirectory.path
+ self.cacheLocation.url = cacheDirectory
+ }
}
}
+ // This is part of the Catalina workaround of showing a Panel
+ @IBAction func validateChangeFolderButton(_ sender: Any) {
+ debugLog("Changed cache Folder to : \(cacheFolderTextField.stringValue)")
+ self.preferences.customCacheDirectory = cacheFolderTextField.stringValue
+ self.cacheLocation.url = URL(fileURLWithPath: cacheFolderTextField.stringValue)
+ changeCacheFolderPanel.close()
+ }
+
@IBAction func resetCacheLocation(_ button: NSButton?) {
preferences.customCacheDirectory = nil
if let cacheDirectory = VideoCache.cacheDirectory {
diff --git a/Aerial/Source/Controllers/PreferencesWindowController.swift b/Aerial/Source/Controllers/PreferencesWindowController.swift
index d3fe1b96..02287f69 100644
--- a/Aerial/Source/Controllers/PreferencesWindowController.swift
+++ b/Aerial/Source/Controllers/PreferencesWindowController.swift
@@ -206,6 +206,10 @@ final class PreferencesWindowController: NSWindowController, NSOutlineViewDataSo
// Quit confirmation Panel
@IBOutlet var quitConfirmationPanel: NSPanel!
+ // Change cache folder Panel
+ @IBOutlet var changeCacheFolderPanel: NSPanel!
+ @IBOutlet var cacheFolderTextField: NSTextField!
+
var player: AVPlayer = AVPlayer()
var videos: [AerialVideo]?
diff --git a/Aerial/Source/Models/Cache/PoiStringProvider.swift b/Aerial/Source/Models/Cache/PoiStringProvider.swift
index a15eba8a..ddcbe7e6 100644
--- a/Aerial/Source/Models/Cache/PoiStringProvider.swift
+++ b/Aerial/Source/Models/Cache/PoiStringProvider.swift
@@ -42,7 +42,7 @@ final class PoiStringProvider {
// Idle string bundle
let preferences = Preferences.sharedInstance
- var bundlePath = VideoCache.cacheDirectory!
+ var bundlePath = VideoCache.appSupportDirectory!
if preferences.localizeDescriptions {
bundlePath.append(contentsOf: "/TVIdleScreenStrings.bundle")
} else {
@@ -50,7 +50,7 @@ final class PoiStringProvider {
}
if let sb = Bundle.init(path: bundlePath) {
- let dictPath = VideoCache.cacheDirectory!.appending("/TVIdleScreenStrings.bundle/en.lproj/Localizable.nocache.strings")
+ let dictPath = VideoCache.appSupportDirectory!.appending("/TVIdleScreenStrings.bundle/en.lproj/Localizable.nocache.strings")
// We could probably only work with that...
if let sd = NSDictionary(contentsOfFile: dictPath) as? [String: String] {
@@ -148,7 +148,7 @@ final class PoiStringProvider {
if #available(OSX 10.12, *) {
// First we look in the Cache Folder for a locale directory
- let cacheDirectory = VideoCache.cacheDirectory!
+ let cacheDirectory = VideoCache.appSupportDirectory!
var cacheResourcesString = cacheDirectory
cacheResourcesString.append(contentsOf: "/locale")
let cacheUrl = URL(fileURLWithPath: cacheResourcesString)
diff --git a/Aerial/Source/Models/Cache/VideoCache.swift b/Aerial/Source/Models/Cache/VideoCache.swift
index 232f8e25..2f02e6bc 100644
--- a/Aerial/Source/Models/Cache/VideoCache.swift
+++ b/Aerial/Source/Models/Cache/VideoCache.swift
@@ -70,7 +70,6 @@ final class VideoCache {
// MARK: - User Video cache directory
static var cacheDirectory: String? {
-
// We only process this once if successful
if computedCacheDirectory != nil {
return computedCacheDirectory
@@ -82,54 +81,39 @@ final class VideoCache {
if let customCacheDirectory = preferences.customCacheDirectory {
// We may have overriden the cache directory, but it may no longer exist !
if FileManager.default.fileExists(atPath: customCacheDirectory as String) {
+ debugLog("Using exiting customCacheDirectory : \(customCacheDirectory)")
cacheDirectory = customCacheDirectory
- } else {
+ } /*else {
// If it doesn't we need to reset that preference
preferences.customCacheDirectory = nil
- }
+ }*/
}
if cacheDirectory == nil {
let userCachePaths = NSSearchPathForDirectoriesInDomains(.cachesDirectory,
.userDomainMask,
true)
- debugLog("userCachePath : \(userCachePaths)")
- if userCachePaths.isEmpty {
- errorLog("Couldn't find cache paths!")
- return nil
- }
- let userCacheDirectory = userCachePaths[0] as NSString
- if #available(OSX 10.15, *) {
- } else {
- // Still look for /Library for pre Catalina OS
- let localCachePaths = NSSearchPathForDirectoriesInDomains(.cachesDirectory,
- .localDomainMask,
- true)
+ let localCachePaths = NSSearchPathForDirectoriesInDomains(.cachesDirectory,
+ .localDomainMask,
+ true)
+
+ if !localCachePaths.isEmpty {
let localCacheDirectory = localCachePaths[0] as NSString
if aerialFolderExists(at: localCacheDirectory) {
- debugLog("local cache exists")
+ debugLog("Using existing local cache /Library/Caches/Aerial")
cacheDirectory = localCacheDirectory.appendingPathComponent("Aerial")
}
}
- if cacheDirectory == nil && aerialFolderExists(at: userCacheDirectory) {
- debugLog("user cache exists")
- cacheDirectory = userCacheDirectory.appendingPathComponent("Aerial")
- } else {
- debugLog("create user cache")
- // We create in user cache directory (~/Library/Caches)
- cacheDirectory = userCacheDirectory.appendingPathComponent("Aerial")
-
- let fileManager = FileManager.default
- if fileManager.fileExists(atPath: cacheDirectory!) == false {
- do {
- try fileManager.createDirectory(atPath: cacheDirectory!,
- withIntermediateDirectories: false, attributes: nil)
- } catch let error {
- errorLog("Couldn't create cache directory in User directory: \(error)")
- errorLog("FATAL : There's nothing more we can do at this point")
- return nil
- }
+ if !userCachePaths.isEmpty {
+ let userCacheDirectory = userCachePaths[0] as NSString
+
+ if cacheDirectory == nil && aerialFolderExists(at: userCacheDirectory) {
+ debugLog("Using existing user cache ~/Library/Caches/Aerial")
+ cacheDirectory = userCacheDirectory.appendingPathComponent("Aerial")
+ } else {
+ debugLog("No local or user cache exists, using ~/Library/Application Support/Aerial")
+ cacheDirectory = appSupportDirectory
}
}
}
diff --git a/Resources/PreferencesWindow.xib b/Resources/PreferencesWindow.xib
index 414475a9..260a207e 100644
--- a/Resources/PreferencesWindow.xib
+++ b/Resources/PreferencesWindow.xib
@@ -21,9 +21,11 @@
+
+
@@ -518,7 +520,7 @@ is disabled
-
+
@@ -540,7 +542,7 @@ is disabled
-
+
@@ -2798,7 +2800,77 @@ Gw
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Your path must end without a / and must be fully formed. For example :
+/Users/MyUser/Aerial (and not ~/Aerial)
+
+After changing the folder, please close System Preferences for this to be taken into account.
+
+
+
+
+
+
+
+
+
+ You can specify an additional cache folder, outside of the sandbox container, where Aerial will look for videos. Please note that new videos will be downloaded in the container folder (you can use the Show in Finder button in Advanced tab to get to that directory). You can manually move videos from this directory to your own specified cache if you wish, but Aerial can no longer do this itself due to sandboxing limitations.
+
+
+
+
+
+
+
+