Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Sources/STFilePath/Compression/STComparator.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if canImport(Compression)
import Foundation
import Compression

Expand Down Expand Up @@ -109,3 +110,4 @@ private extension STComparator {
}

}
#endif
2 changes: 2 additions & 0 deletions Sources/STFilePath/DownloadableFile/DownloadableFile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public extension DownloadableFile {
DFFileMap(file: self, fetch: fetch, save: save)
}

#if canImport(Compression)
/// [en] Compresses and decompresses the file data using the specified algorithm.
/// [zh] 使用指定的算法压缩和解压缩文件数据。
/// - Parameter algorithm: The compression algorithm to use.
Expand All @@ -66,6 +67,7 @@ public extension DownloadableFile {
try STComparator.compress(model, algorithm: algorithm)
}
}
#endif

/// [en] Maps the file data to a `Codable` type.
/// [zh] 将文件数据映射到 `Codable` 类型。
Expand Down
2 changes: 2 additions & 0 deletions Tests/STFilePathTests/DownloadableFileTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ struct DownloadableFileTests {
#expect(fetchedModel2 != model1)
}

#if canImport(Compression)
@Test("Compression Transformation")
func testCompression() async throws {
let testFolder = try createTestFolder()
Expand All @@ -56,4 +57,5 @@ struct DownloadableFileTests {
let decompressedData = try await downloadableFile.fetch()
#expect(decompressedData == originalData)
}
#endif
}
2 changes: 2 additions & 0 deletions Tests/STFilePathTests/Test.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Foundation
import STFilePath
import Testing

#if canImport(Compression)
struct CompressionTest {

@Test func testCompressionRoundTrip() throws {
Expand All @@ -23,3 +24,4 @@ struct CompressionTest {
}

}
#endif
Loading