Skip to content

Commit d05d5a8

Browse files
committed
Use the previous save directory
If the input directory is not suitable. Fixes #296
1 parent f1d46ea commit d05d5a8

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

Gifski/Constants.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ extension Defaults.Keys {
2424
static let loopGif = Key<Bool>("loopGif", default: true)
2525
static let bounceGif = Key<Bool>("bounceGif", default: false)
2626
static let suppressKeyframeWarning = Key<Bool>("suppressKeyframeWarning", default: false)
27+
static let previousSaveDirectory = Key<URL?>("previousSaveDirectory")
2728
}

Gifski/ConversionCompletedViewController.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ final class ConversionCompletedViewController: NSViewController {
178178
// Prevent the default directory to be a temporary directory or read-only volume, for example, when directly dragging a screen recording into Gifski. Setting it to the downloads directory is required as otherwise it will automatically use the same directory as used in the open panel, which could be a read-only volume.
179179
panel.directoryURL = inputUrl.directoryURL.canBeDefaultSavePanelDirectory
180180
? inputUrl.directoryURL
181-
: URL.downloadsDirectory
181+
: (Defaults[.previousSaveDirectory] ?? URL.downloadsDirectory)
182182

183183
panel.beginSheetModal(for: view.window!) { [weak self] response in
184184
guard
@@ -193,6 +193,7 @@ final class ConversionCompletedViewController: NSViewController {
193193
DispatchQueue.main.async {
194194
do {
195195
try FileManager.default.copyItem(at: self.gifUrl, to: outputUrl, overwrite: true)
196+
Defaults[.previousSaveDirectory] = outputUrl.directoryURL
196197
} catch {
197198
error.presentAsModalSheet(for: self.view.window)
198199
self.saveGif()

Gifski/GifskiWrapper.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Foundation
22

3+
// TODO: Make it an actor.
34
final class GifskiWrapper {
45
enum PixelFormat {
56
case rgba

0 commit comments

Comments
 (0)