Skip to content
Closed
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
17 changes: 12 additions & 5 deletions ios/Sources/GutenbergKit/Sources/Services/EditorService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,22 @@ public actor EditorService {
self.progress = EditorProgress(completed: 1, total: 100)
self.progressCallback = progress

// Automatically clean up old asset bundles.
// Cleanup errors are intentionally ignored so that the download process
// continues uninterrupted. Failures are expected when running for the
// first time, since the storage directories may not yet exist.
await onceEvery(.seconds(86_400)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it may be worth reconsidering the "once every x interval" implementation.

The "handle" of this timestamp is static, which means one timestamp applies to all sites. At the bare minimum, the timestamp should be stored per site (configuration.siteURL).

Since we'll be supporting multiple post types, the number of handles will be N(sites) x N(post types). I don't feel like UserDefaults is the right place to store that data.

What do you think about using the last modified date of the manifest.json as the timestamp, so that we don't need to store any more timestamps anywhere?

do {
try await self.cleanup()
} catch {
log(.warn, "Failed to cleanup old asset bundles: \(error)")
}
}

async let settings = try prepareEditorSettings()
async let assetBundle = try self.prepareAssetBundle()
async let preloadList = try preparePreloadList()

// Automatically clean up old asset bundles
try await onceEvery(.seconds(86_400)) {
try await self.cleanup()
}

return try await EditorDependencies(
editorSettings: settings,
assetBundle: assetBundle,
Expand Down
Loading