Skip to content

Commit 0396c02

Browse files
Fix file naming
1 parent bf594ae commit 0396c02

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

Sources/Alchemy/Encryption/Encrypted.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
@propertyWrapper
2-
public struct Encrypted: ModelProperty {
2+
public struct Encrypted: ModelProperty, Codable {
33
public var wrappedValue: String
44

55
// MARK: ModelProperty
66

77
public init(key: String, on row: SQLRowReader) throws {
8-
let encrypted = try row.require(key).string()
8+
let encrypted = try row.require(key).string(key)
99
guard let data = Data(base64Encoded: encrypted) else {
1010
throw EncryptionError("could not decrypt data; it wasn't base64 encoded")
1111
}

Sources/Alchemy/Filesystem/File.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public struct File: Codable, ResponseConvertible, ModelProperty {
1010
// The file came with the given ContentType from an HTTP request.
1111
case http(clientContentType: ContentType?)
1212

13-
static var raw: Source {
13+
public static var raw: Source {
1414
.http(clientContentType: nil)
1515
}
1616
}
@@ -89,7 +89,7 @@ public struct File: Codable, ResponseConvertible, ModelProperty {
8989
// MARK: ModelProperty
9090

9191
public init(key: String, on row: SQLRowReader) throws {
92-
let name = try row.require(key).string()
92+
let name = try row.require(key).string(key)
9393
self.init(name: name, source: .filesystem(Storage, path: name))
9494
}
9595

Sources/Alchemy/Filesystem/Filesystem.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public struct Filesystem: Service {
6969
extension File {
7070
@discardableResult
7171
public func store(on filesystem: Filesystem = Storage, in directory: String? = nil, as name: String? = nil) async throws -> File {
72-
let name = name ?? (UUID().uuidString + `extension`)
72+
let name = name ?? ("\(UUID().uuidString).\(`extension`)")
7373
return try await filesystem.put(self, in: directory, as: name)
7474
}
7575
}

0 commit comments

Comments
 (0)