Skip to content

Commit

Permalink
Use the previous save directory
Browse files Browse the repository at this point in the history
If the input directory is not suitable.

Fixes #296
  • Loading branch information
sindresorhus committed Feb 21, 2023
1 parent f1d46ea commit d05d5a8
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions Gifski/Constants.swift
Expand Up @@ -24,4 +24,5 @@ extension Defaults.Keys {
static let loopGif = Key<Bool>("loopGif", default: true)
static let bounceGif = Key<Bool>("bounceGif", default: false)
static let suppressKeyframeWarning = Key<Bool>("suppressKeyframeWarning", default: false)
static let previousSaveDirectory = Key<URL?>("previousSaveDirectory")
}
3 changes: 2 additions & 1 deletion Gifski/ConversionCompletedViewController.swift
Expand Up @@ -178,7 +178,7 @@ final class ConversionCompletedViewController: NSViewController {
// 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.
panel.directoryURL = inputUrl.directoryURL.canBeDefaultSavePanelDirectory
? inputUrl.directoryURL
: URL.downloadsDirectory
: (Defaults[.previousSaveDirectory] ?? URL.downloadsDirectory)

panel.beginSheetModal(for: view.window!) { [weak self] response in
guard
Expand All @@ -193,6 +193,7 @@ final class ConversionCompletedViewController: NSViewController {
DispatchQueue.main.async {
do {
try FileManager.default.copyItem(at: self.gifUrl, to: outputUrl, overwrite: true)
Defaults[.previousSaveDirectory] = outputUrl.directoryURL
} catch {
error.presentAsModalSheet(for: self.view.window)
self.saveGif()
Expand Down
1 change: 1 addition & 0 deletions Gifski/GifskiWrapper.swift
@@ -1,5 +1,6 @@
import Foundation

// TODO: Make it an actor.
final class GifskiWrapper {
enum PixelFormat {
case rgba
Expand Down

0 comments on commit d05d5a8

Please sign in to comment.