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
21 changes: 17 additions & 4 deletions Loop.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,7 @@
C16B983E26B4893300256B05 /* DoseEnactor.swift in Sources */ = {isa = PBXBuildFile; fileRef = C16B983D26B4893300256B05 /* DoseEnactor.swift */; };
C16B984026B4898800256B05 /* DoseEnactorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C16B983F26B4898800256B05 /* DoseEnactorTests.swift */; };
C16DA84222E8E112008624C2 /* PluginManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = C16DA84122E8E112008624C2 /* PluginManager.swift */; };
C1735B1E2A0809830082BB8A /* ZIPFoundation in Frameworks */ = {isa = PBXBuildFile; productRef = C1735B1D2A0809830082BB8A /* ZIPFoundation */; };
C1742332259BEADC00399C9D /* ManualEntryDoseView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1742331259BEADC00399C9D /* ManualEntryDoseView.swift */; };
C174233C259BEB0F00399C9D /* ManualEntryDoseViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C174233B259BEB0F00399C9D /* ManualEntryDoseViewModel.swift */; };
C1777A6625A125F100595963 /* ManualEntryDoseViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1777A6525A125F100595963 /* ManualEntryDoseViewModelTests.swift */; };
Expand All @@ -476,8 +477,6 @@
C191D2A125B3ACAA00C26C0B /* DosingStrategySelectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C191D2A025B3ACAA00C26C0B /* DosingStrategySelectionView.swift */; };
C19C8BBA28651DFB0056D5E4 /* TrueTime.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C19C8BB928651DFB0056D5E4 /* TrueTime.framework */; };
C19C8BBB28651DFB0056D5E4 /* TrueTime.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = C19C8BB928651DFB0056D5E4 /* TrueTime.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
C19C8BBC28651E1C0056D5E4 /* Minizip.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C1750AEB255B013300B8011C /* Minizip.framework */; };
C19C8BBD28651E1C0056D5E4 /* Minizip.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = C1750AEB255B013300B8011C /* Minizip.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
C19C8BBE28651E3D0056D5E4 /* LoopKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 43F78D4B1C914197002152D1 /* LoopKit.framework */; };
C19C8BBF28651E3D0056D5E4 /* LoopKit.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 43F78D4B1C914197002152D1 /* LoopKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
C19C8BC328651EAE0056D5E4 /* LoopTestingKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C19C8BC228651EAE0056D5E4 /* LoopTestingKit.framework */; };
Expand Down Expand Up @@ -726,7 +725,6 @@
4F2C159A1E0C9E5600E160D4 /* LoopUI.framework in Embed Frameworks */,
C19C8BCF28651F520056D5E4 /* LoopKitUI.framework in Embed Frameworks */,
C11B9D63286779C000500CF8 /* MockKit.framework in Embed Frameworks */,
C19C8BBD28651E1C0056D5E4 /* Minizip.framework in Embed Frameworks */,
C19C8BBB28651DFB0056D5E4 /* TrueTime.framework in Embed Frameworks */,
C11B9D65286779C000500CF8 /* MockKitUI.framework in Embed Frameworks */,
C1F00C78285A8256006302C5 /* SwiftCharts in Embed Frameworks */,
Expand Down Expand Up @@ -1821,14 +1819,14 @@
C1D6EEA02A06C7270047DE5C /* MKRingProgressView in Frameworks */,
43F5C2C91B929C09003EB13D /* HealthKit.framework in Frameworks */,
43D9FFD621EAE05D00AF44BF /* LoopCore.framework in Frameworks */,
C19C8BBC28651E1C0056D5E4 /* Minizip.framework in Frameworks */,
C11B9D64286779C000500CF8 /* MockKitUI.framework in Frameworks */,
4F7528941DFE1E9500C322D6 /* LoopUI.framework in Frameworks */,
C11B9D62286779C000500CF8 /* MockKit.framework in Frameworks */,
C19C8BBE28651E3D0056D5E4 /* LoopKit.framework in Frameworks */,
C19C8BBA28651DFB0056D5E4 /* TrueTime.framework in Frameworks */,
C1F00C60285A802A006302C5 /* SwiftCharts in Frameworks */,
C19C8BC328651EAE0056D5E4 /* LoopTestingKit.framework in Frameworks */,
C1735B1E2A0809830082BB8A /* ZIPFoundation in Frameworks */,
C19C8BCE28651F520056D5E4 /* LoopKitUI.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -3140,6 +3138,7 @@
packageProductDependencies = (
C1F00C5F285A802A006302C5 /* SwiftCharts */,
C1D6EE9F2A06C7270047DE5C /* MKRingProgressView */,
C1735B1D2A0809830082BB8A /* ZIPFoundation */,
);
productName = Loop;
productReference = 43776F8C1B8022E90074EA36 /* Loop.app */;
Expand Down Expand Up @@ -3464,6 +3463,7 @@
packageReferences = (
C1CCF10B2858F4F70035389C /* XCRemoteSwiftPackageReference "SwiftCharts" */,
C1D6EE9E2A06C7270047DE5C /* XCRemoteSwiftPackageReference "MKRingProgressView" */,
C1735B1C2A0809830082BB8A /* XCRemoteSwiftPackageReference "ZIPFoundation" */,
);
productRefGroup = 43776F8D1B8022E90074EA36 /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -5883,6 +5883,14 @@
/* End XCConfigurationList section */

/* Begin XCRemoteSwiftPackageReference section */
C1735B1C2A0809830082BB8A /* XCRemoteSwiftPackageReference "ZIPFoundation" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/LoopKit/ZIPFoundation.git";
requirement = {
branch = "stream-entry";
kind = branch;
};
};
C1CCF10B2858F4F70035389C /* XCRemoteSwiftPackageReference "SwiftCharts" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/ivanschuetz/SwiftCharts";
Expand All @@ -5907,6 +5915,11 @@
package = C1CCF10B2858F4F70035389C /* XCRemoteSwiftPackageReference "SwiftCharts" */;
productName = SwiftCharts;
};
C1735B1D2A0809830082BB8A /* ZIPFoundation */ = {
isa = XCSwiftPackageProductDependency;
package = C1735B1C2A0809830082BB8A /* XCRemoteSwiftPackageReference "ZIPFoundation" */;
productName = ZIPFoundation;
};
C1CCF1162858FBAD0035389C /* SwiftCharts */ = {
isa = XCSwiftPackageProductDependency;
package = C1CCF10B2858F4F70035389C /* XCRemoteSwiftPackageReference "SwiftCharts" */;
Expand Down
2 changes: 1 addition & 1 deletion Loop/Managers/Alerts/AlertStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ extension AlertStore: CriticalEventLog {
return result!
}

public func export(startDate: Date, endDate: Date, to stream: OutputStream, progress: Progress) -> Error? {
public func export(startDate: Date, endDate: Date, to stream: DataOutputStream, progress: Progress) -> Error? {
let encoder = JSONStreamEncoder(stream: stream)
var modificationCounter: Int64 = 0
var fetching = true
Expand Down
32 changes: 21 additions & 11 deletions Loop/Managers/CriticalEventLogExportManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ public class CriticalEventLogBaseExporter {
}
}

fileprivate func export(startDate: Date, endDate: Date, to url: URL, compression: ZipArchive.Compression, progress: Progress) -> Error? {
fileprivate func export(startDate: Date, endDate: Date, to url: URL, progress: Progress) -> Error? {
guard !progress.isCancelled else {
return CriticalEventLogError.cancelled
}
Expand All @@ -261,24 +261,32 @@ public class CriticalEventLogBaseExporter {
defer { archive.close() }

for log in manager.logs {
if let error = export(startDate: startDate, endDate: endDate, from: log, to: archive, compression: compression, progress: progress) {
if let error = export(startDate: startDate, endDate: endDate, from: log, to: archive, progress: progress) {
return error
}
}

return archive.close()
}

private func export(startDate: Date, endDate: Date, from log: CriticalEventLog, to archive: ZipArchive, compression: ZipArchive.Compression, progress: Progress) -> Error? {
private func export(startDate: Date, endDate: Date, from log: CriticalEventLog, to archive: ZipArchive, progress: Progress) -> Error? {
guard !progress.isCancelled else {
return CriticalEventLogError.cancelled
}

let stream = archive.createArchiveFile(withPath: log.exportName, compression: compression)
stream.open()
defer { stream.close() }
let stream = archive.createArchiveFile(withPath: log.exportName)

return log.export(startDate: startDate, endDate: endDate, to: stream, progress: progress)
if let error = log.export(startDate: startDate, endDate: endDate, to: stream, progress: progress) {
return error
}

do {
try stream.finish(sync: true)
} catch {
return error
}

return nil
}

fileprivate func historicalDate(from now: Date) -> Date { manager.exportDate(for: manager.date(byAddingDays: -Int(manager.historicalDuration.days), to: now)) }
Expand Down Expand Up @@ -334,7 +342,7 @@ public class CriticalEventLogHistoricalExporter: CriticalEventLogBaseExporter, C
let temporaryFileURL = manager.fileManager.temporaryFileURL
defer { try? manager.fileManager.removeItem(at: temporaryFileURL) }

if let error = export(startDate: startDate, endDate: endDate, to: temporaryFileURL, compression: .bestCompression, progress: progress) {
if let error = export(startDate: startDate, endDate: endDate, to: temporaryFileURL, progress: progress) {
return error
}

Expand Down Expand Up @@ -431,7 +439,7 @@ public class CriticalEventLogFullExporter: CriticalEventLogBaseExporter, Critica

log.default("Exporting %{public}@...", recentFileURL.lastPathComponent)

if let error = export(startDate: manager.recentDate(from: now), endDate: now, to: recentTemporaryFileURL, compression: .bestSpeed, progress: progress) {
if let error = export(startDate: manager.recentDate(from: now), endDate: now, to: recentTemporaryFileURL, progress: progress) {
return error
}

Expand Down Expand Up @@ -460,7 +468,8 @@ public class CriticalEventLogFullExporter: CriticalEventLogBaseExporter, Critica
date = manager.date(byAddingDays: 1, to: date)

let exportFileURL = exportsFileURL(for: date)
if let error = archive.createArchiveFile(withPath: exportFileURL.lastPathComponent, contentsOf: exportFileURL) {
log.default("Bundling %{public}@", exportFileURL.lastPathComponent)
if let error = archive.createArchiveFile(withPath: exportFileURL.lastPathComponent, contentsOf: exportFileURL, compressionMethod: .none) {
return error
}

Expand All @@ -471,7 +480,8 @@ public class CriticalEventLogFullExporter: CriticalEventLogBaseExporter, Critica
return CriticalEventLogError.cancelled
}

if let error = archive.createArchiveFile(withPath: recentFileURL.lastPathComponent, contentsOf: recentTemporaryFileURL) {
log.default("Bundling %{public}@", recentFileURL.lastPathComponent)
if let error = archive.createArchiveFile(withPath: recentFileURL.lastPathComponent, contentsOf: recentTemporaryFileURL, compressionMethod: .none) {
return error
}

Expand Down
Loading