Comments (5)
Same thing happens even when using defaultStore(). If I rebuild and try and run a second time and write to the store, on write attempt I get the error "Is a directory"
from codabledatastore.
I believe this line is the source of the issue:
let data = try Data(contentsOf: snapshotURL)
/Persistence/Disk Persistence/Snapshot/Snapshot.swift (line 91)
https://github.com/mochidev/CodableDatastore/blob/b02fdbaca2048079e9f0027d89e6914b2be63137/Sources/CodableDatastore/Persistence/Disk%20Persistence/Snapshot/Snapshot.swift#L91C54-L91C54
from codabledatastore.
Here is a more full, simple example using the latest release (0.0.29). This example with just two files runs fine on first run, but fails on second run. I am using Xcode 15 beta 4 and have. tried the iOS simulator and building for Mac:
Persistence.swift
import CodableDatastore
final class Persistence {
func write() async throws {
enum Version: Int, CaseIterable {
case zero
}
struct TestStruct: Codable, Identifiable {
var id: String
var value: String
}
let persistence = try DiskPersistence.defaultStore()
let datastore = Datastore.JSONStore(
persistence: persistence,
key: "test",
version: Version.zero,
migrations: [
.zero: { data, decoder in
try decoder.decode(TestStruct.self, from: data)
}
]
)
try await datastore.persist(TestStruct(id: "3", value: "My name is Dimitri"))
try await datastore.persist(TestStruct(id: "1", value: "Hello, World!"))
try await datastore.persist(TestStruct(id: "2", value: "Twenty Three is Number One"))
let count = try await datastore.count
}
}
TestApp.swift
import SwiftUI
@main
struct CodableDatastore29App: App {
var store = Persistence()
var body: some Scene {
WindowGroup {
EmptyView()
.task {
try! await store.write()
}
}
}
}
from codabledatastore.
Good catch! I'm embarrassed to say that I haven't written any tests that re-load the entire datastore from disk yet, so I fully expect you to find more issues 😅
from codabledatastore.
Told you I'd find more 😅:
from codabledatastore.
Related Issues (20)
- Rename load(_ range:)
- Improve ergonomics of using computed indexes
- Indexed should conditionally conform to Hashable
- Add contains variant to datastore
- Add deleteIfPresent method that doesn't throw if the entry is missing
- Store indexed lookups in the primary datastore to aid in deletions HOT 1
- Indexed values should be required to conform to IndexComparable HOT 1
- Consider flipping data and decoder in migrations
- Add support for Many to One indexes
- Persist methods should return their old values
- Add sparse set lookups
- Add a type for automatically dealing with compound indexes
- Add .exact to IndexRangeExpression
- Switch to `String(reflecting:)` in descriptors
- Gracefully migrate from `*.datastore/SecondaryIndexes` to `*.datastore/ReferenceIndexes`
- Provide better support for mismatched versions during migrations
- Manifests should be paged
- Mark transactions with `@_implicitSelfCapture`
- Check KeyPath Sendability when Swift 6 is released HOT 1
- Indexes containing dates may not be updatable or deletable
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from codabledatastore.