NSPersistentDocument, Export (Save As) and wal/shm
NSPersistentDocument, Export (Save As) and wal/shm
- Subject: NSPersistentDocument, Export (Save As) and wal/shm
- From: Fritz Anderson <email@hidden>
- Date: Fri, 14 Nov 2014 17:45:13 -0600
OS X application, Yosemite (host and target), Xcode 6.1, all-Swift. If you duplicate (save-as) an existing document, the new document appears on disk with external journaling files (SHM, WAL).
It is impossible to state how undesirable this is without descending into sarcasm.
The solutions I’ve seen from a web search are a year or more old, and have proven ineffective.
What is the current thinking on this? This is another of those things that are so conspicuous that I must be missing something obvious.
Details below the fold.
— F
This concern seems to have been perking along since the introduction of Mavericks.
One commenter said DTS volunteered these solutions:
1. Continue to use the Mountain Lion SDK for Mavericks development.
2. Swizzle something. I stopped reading.
Time’s run out on those.
A year ago, it was suggested on this list that the persistent-document subclass should override the method for which the Swift signature is:
configurePersistentStoreCoordinatorForURL(_: NSURL!,
ofType: String!,
modelConfiguration: String?,
storeOptions: [NSObject : AnyObject]!,
error: NSErrorPointer) -> Bool
… and pass @{ NSSQLitePragmasOption : @{ @"journal_mode" : @"DELETE" } } as storeOptions: to super. With that pragma set, SQLite is supposed to suppress the journal files.
An account of the strong-typing nightmare would veer once again into sarcasm. I’m unhappy about assuming storeOptions will always be nil.
Here is my attempt:
```
let newOpts = [NSSQLitePragmasOption : ["journal_mode" : "DELETE"]]
// Also suggested:
// let newOpts = ["JOURNAL":"DELETE"]
// This doesn’t work, either.
return super.configurePersistentStoreCoordinatorForURL(url,
ofType: fileType, modelConfiguration: configuration,
storeOptions: newOpts, error: error)
```
The breakpoint at the return line fires. newOpts has the expected content. I still get WAL and SHM files. Using … ["journal_mode" : "OFF"]] does no better.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden