Skip to content

Commit f832300

Browse files
committed
fix key loading issue
1 parent 30a932a commit f832300

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

Sources/Command/RegisterCommand.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,7 @@ extension LCLCLI {
103103
try encryptAndWriteData(signature, to: sigURL, using: symmetricKey)
104104

105105
let symmetricKeyData = symmetricKey.withUnsafeBytes { pointer in
106-
let ret = pointer.load(as: Data.self)
107-
pointer.deallocate()
108-
return ret
106+
return Data(pointer)
109107
}
110108

111109
try FileIO.default.write(data: symmetricKeyData, to: keyURL)

Sources/IO/IO+File.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class FileIO {
3131
}
3232

3333
func loadFrom(_ url: URL) throws -> Data? {
34-
return self.fileManager.contents(atPath: url.absoluteString)
34+
return self.fileManager.contents(atPath: url.relativePath)
3535
}
3636

3737
func readLines(from url: URL) throws -> [Data] {
@@ -74,21 +74,21 @@ class FileIO {
7474
}
7575

7676
func fileExists(_ url: URL) -> Bool {
77-
return self.fileManager.fileExists(atPath: url.absoluteString)
77+
return self.fileManager.fileExists(atPath: url.relativePath)
7878
}
7979

8080
func createIfAbsent(at name: URL, isDirectory: Bool) throws {
8181
if isDirectory {
82-
try self.fileManager.createDirectory(at: name, withIntermediateDirectories: true)
82+
try self.fileManager.createDirectory(atPath: name.relativePath, withIntermediateDirectories: true)
8383
} else {
8484
// file
85-
self.fileManager.createFile(atPath: name.absoluteString, contents: nil)
85+
self.fileManager.createFile(atPath: name.relativePath, contents: nil)
8686
}
8787
}
8888

8989
func attributesOf(_ fileURL: URL) throws -> [FileAttributeKey: Any] {
9090
if self.fileExists(fileURL) {
91-
return try self.fileManager.attributesOfItem(atPath: fileURL.absoluteString)
91+
return try self.fileManager.attributesOfItem(atPath: fileURL.relativePath)
9292
}
9393

9494
return [FileAttributeKey.size: 0]
@@ -99,6 +99,6 @@ class FileIO {
9999
}
100100

101101
func remove(at fileURL: URL) throws {
102-
try self.fileManager.removeItem(atPath: fileURL.absoluteString)
102+
try self.fileManager.removeItem(atPath: fileURL.relativePath)
103103
}
104104
}

0 commit comments

Comments
 (0)