@@ -17,14 +17,14 @@ import TSCUtility
17
17
18
18
public struct FilePackageFingerprintStorage : PackageFingerprintStorage {
19
19
let fileSystem : FileSystem
20
- let directory : AbsolutePath
20
+ let directoryPath : AbsolutePath
21
21
22
22
private let encoder : JSONEncoder
23
23
private let decoder : JSONDecoder
24
24
25
- init ( customFileSystem : FileSystem ? = nil , customDirectory : AbsolutePath ? = nil ) {
26
- self . fileSystem = customFileSystem ?? localFileSystem
27
- self . directory = customDirectory ?? self . fileSystem . dotSwiftPM . appending ( component : " fingerprints " )
25
+ init ( fileSystem : FileSystem , directoryPath : AbsolutePath ) {
26
+ self . fileSystem = fileSystem
27
+ self . directoryPath = directoryPath
28
28
29
29
self . encoder = JSONEncoder . makeWithDefaults ( )
30
30
self . decoder = JSONDecoder . makeWithDefaults ( )
@@ -88,7 +88,7 @@ public struct FilePackageFingerprintStorage: PackageFingerprintStorage {
88
88
}
89
89
90
90
private func loadFromDisk( package : PackageIdentity ) throws -> PackageFingerprints {
91
- let path = self . directory . appending ( component: package . fingerprintFilename)
91
+ let path = self . directoryPath . appending ( component: package . fingerprintFilename)
92
92
93
93
guard self . fileSystem. exists ( path) else {
94
94
return . init( )
@@ -104,22 +104,22 @@ public struct FilePackageFingerprintStorage: PackageFingerprintStorage {
104
104
}
105
105
106
106
private func saveToDisk( package : PackageIdentity , fingerprints: PackageFingerprints ) throws {
107
- if !self . fileSystem. exists ( self . directory ) {
108
- try self . fileSystem. createDirectory ( self . directory , recursive: true )
107
+ if !self . fileSystem. exists ( self . directoryPath ) {
108
+ try self . fileSystem. createDirectory ( self . directoryPath , recursive: true )
109
109
}
110
110
111
111
let container = StorageModel . Container ( fingerprints)
112
112
let buffer = try encoder. encode ( container)
113
113
114
- let path = self . directory . appending ( component: package . fingerprintFilename)
114
+ let path = self . directoryPath . appending ( component: package . fingerprintFilename)
115
115
try self . fileSystem. writeFileContents ( path, bytes: ByteString ( buffer) )
116
116
}
117
117
118
118
private func withLock< T> ( _ body: ( ) throws -> T ) throws -> T {
119
- if !self . fileSystem. exists ( self . directory ) {
120
- try self . fileSystem. createDirectory ( self . directory , recursive: true )
119
+ if !self . fileSystem. exists ( self . directoryPath ) {
120
+ try self . fileSystem. createDirectory ( self . directoryPath , recursive: true )
121
121
}
122
- return try self . fileSystem. withLock ( on: self . directory , type: . exclusive, body)
122
+ return try self . fileSystem. withLock ( on: self . directoryPath , type: . exclusive, body)
123
123
}
124
124
125
125
private func makeAsync< T> ( _ closure: @escaping ( Result < T , Error > ) -> Void , on queue: DispatchQueue ) -> ( Result < T , Error > ) -> Void {
0 commit comments