Commit 4a1e3eff authored by Soomin Lee's avatar Soomin Lee
Browse files

VLCMediaLibraryManager: Organize dbPath and thumbnailPath

parent 128a7043
...@@ -68,8 +68,6 @@ extension NSNotification { ...@@ -68,8 +68,6 @@ extension NSNotification {
class VLCMediaLibraryManager: NSObject { class VLCMediaLibraryManager: NSObject {
private static let databaseName: String = "medialibrary.db" private static let databaseName: String = "medialibrary.db"
private var databasePath: String!
private var thumbnailPath: String!
// Using ObjectIdentifier to avoid duplication and facilitate // Using ObjectIdentifier to avoid duplication and facilitate
// identification of observing object // identification of observing object
...@@ -89,14 +87,22 @@ class VLCMediaLibraryManager: NSObject { ...@@ -89,14 +87,22 @@ class VLCMediaLibraryManager: NSObject {
} }
// MARK: Private // MARK: Private
private func setupMediaLibrary() { private func setupMediaLibrary() {
guard let documentPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first, guard let documentPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first,
let dbPath = NSSearchPathForDirectoriesInDomains(.libraryDirectory, .userDomainMask, true).first else { let libraryPath = NSSearchPathForDirectoriesInDomains(.libraryDirectory, .userDomainMask, true).first else {
preconditionFailure("VLCMediaLibraryManager: Unable to init medialibrary.") preconditionFailure("VLCMediaLibraryManager: Unable to init medialibrary.")
} }
databasePath = dbPath + "/" + VLCMediaLibraryManager.databaseName let databasePath = libraryPath + "/MediaLibrary/" + VLCMediaLibraryManager.databaseName
thumbnailPath = documentPath let thumbnailPath = libraryPath + "/MediaLibrary/Thumbnails"
do {
try FileManager.default.createDirectory(atPath: thumbnailPath,
withIntermediateDirectories: true)
} catch let error as NSError {
assertionFailure("Failed to create directory: \(error.localizedDescription)")
}
let medialibraryStatus = medialib.setupMediaLibrary(databasePath: databasePath, let medialibraryStatus = medialib.setupMediaLibrary(databasePath: databasePath,
thumbnailPath: thumbnailPath) thumbnailPath: thumbnailPath)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment