Skip to content

Commit

Permalink
change(SabyAppleStorage, SabyApplePreference): add Version1 to name o…
Browse files Browse the repository at this point in the history
…f file
  • Loading branch information
0xWOF committed May 24, 2024
1 parent 4caff72 commit c624f1f
Show file tree
Hide file tree
Showing 11 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Source/ApplePreference/Implement/FileValuePreference.swift
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ struct FileValuePreferenceContext<Value: Codable> {
)
}

let url = directoryURL.appendingPathComponent(storageName).appendingPathExtension(STORAGE_VERSION)
let url = directoryURL.appendingPathComponent("\(storageName)_\(STORAGE_VERSION)")
if !fileManager.fileExists(atPath: url.path) {
return FileValuePreferenceContext(
url: url,
Expand Down
4 changes: 2 additions & 2 deletions Source/ApplePreference/Preference.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import Foundation
public protocol Preference {
/// ``init(directoryURL:storageName:migration:)``
/// execute migration and then create or load preference from
/// `{Directory url}/{Storage name}/{Version name}` path.
/// `{Directory url}/{Storage name}_{Version name}` path.
init(directoryURL: URL, storageName: String, migration: @escaping () throws -> Void)
}

extension Preference {
/// ``init(directoryName:storageName:)`` create or load storage from
/// `{Directory url}/{Storage name}/{Version name}` path.
/// `{Directory url}/{Storage name}_{Version name}` path.
public init(directoryURL: URL, storageName: String) {
self.init(directoryURL: directoryURL, storageName: storageName, migration: {})
}
Expand Down
2 changes: 1 addition & 1 deletion Source/AppleStorage/Implement/CoreDataArrayStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ extension NSManagedObjectContext {
)
}

let url = directoryURL.appendingPathComponent(storageName).appendingPathExtension(STORAGE_VERSION)
let url = directoryURL.appendingPathComponent("\(storageName)_\(STORAGE_VERSION)")

let container = NSPersistentContainer(
name: storageName,
Expand Down
2 changes: 1 addition & 1 deletion Source/AppleStorage/Implement/FileArrayStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ struct FileArrayStorageContext<Value: Codable> {
)
}

let url = directoryURL.appendingPathComponent(storageName).appendingPathExtension(STORAGE_VERSION)
let url = directoryURL.appendingPathComponent("\(storageName)_\(STORAGE_VERSION)")
if !fileManager.fileExists(atPath: url.path) {
return FileArrayStorageContext(
url: url,
Expand Down
2 changes: 1 addition & 1 deletion Source/AppleStorage/Implement/FileDictionaryStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ struct FileDictionaryStorageContext<Key: Hashable & Codable, Value: Codable> {
)
}

let url = directoryURL.appendingPathComponent(storageName).appendingPathExtension(STORAGE_VERSION)
let url = directoryURL.appendingPathComponent("\(storageName)_\(STORAGE_VERSION)")
if !fileManager.fileExists(atPath: url.path) {
return FileDictionaryStorageContext(
url: url,
Expand Down
2 changes: 1 addition & 1 deletion Source/AppleStorage/Implement/FileValueStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ struct FileValueStorageContext<Value: Codable> {
)
}

let url = directoryURL.appendingPathComponent(storageName).appendingPathExtension(STORAGE_VERSION)
let url = directoryURL.appendingPathComponent("\(storageName)_\(STORAGE_VERSION)")
if !fileManager.fileExists(atPath: url.path) {
return FileValueStorageContext(
url: url,
Expand Down
4 changes: 2 additions & 2 deletions Source/AppleStorage/Storage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ import SabyConcurrency
public protocol Storage {
/// ``init(directoryURL:storageName:migration:)``
/// execute migration and then create or load preference from
/// `{Directory url}/{Storage name}/{Version name}` path.
/// `{Directory url}/{Storage name}_{Version name}` path.
init(directoryURL: URL, storageName: String, migration: @escaping () -> Promise<Void, Error>)
}

extension Storage {
/// ``init(directoryName:storageName:)`` create or load storage from
/// `{Directory url}/{Storage name}/{Version name}` path.
/// `{Directory url}/{Storage name}_{Version name}` path.
public init(directoryURL: URL, storageName: String) {
self.init(directoryURL: directoryURL, storageName: storageName, migration: { .resolved(()) })
}
Expand Down
2 changes: 1 addition & 1 deletion Test/ApplePreference/FileValuePreferenceTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ final class FileValuePreferenceTest: XCTestCase {
}

override func tearDownWithError() throws {
let fileURL = directoryURL.appendingPathComponent(storageName)
let fileURL = directoryURL

if FileManager.default.fileExists(atPath: fileURL.absoluteString) {
try FileManager.default.removeItem(at: fileURL)
Expand Down
2 changes: 1 addition & 1 deletion Test/AppleStorage/Implement/FileArrayStorageTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ final class FileArrayStorageTest: XCTestCase {
}

override func tearDownWithError() throws {
let fileURL = directoryURL.appendingPathComponent(storageName)
let fileURL = directoryURL

if FileManager.default.fileExists(atPath: fileURL.absoluteString) {
try FileManager.default.removeItem(at: fileURL)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ final class FileDictionaryStorageTest: XCTestCase {
}

override func tearDownWithError() throws {
let fileURL = directoryURL.appendingPathComponent(storageName)
let fileURL = directoryURL

if FileManager.default.fileExists(atPath: fileURL.absoluteString) {
try FileManager.default.removeItem(at: fileURL)
Expand Down
2 changes: 1 addition & 1 deletion Test/AppleStorage/Implement/FileValueStorageTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ final class FileValueStorageTest: XCTestCase {
}

override func tearDownWithError() throws {
let fileURL = directoryURL.appendingPathComponent(storageName)
let fileURL = directoryURL

if FileManager.default.fileExists(atPath: fileURL.absoluteString) {
try FileManager.default.removeItem(at: fileURL)
Expand Down

0 comments on commit c624f1f

Please sign in to comment.