Skip to content

Commit

Permalink
Fix temporary directory not being removed on close
Browse files Browse the repository at this point in the history
  • Loading branch information
johnfactotum committed Jul 19, 2019
1 parent 9db0250 commit c3d4b39
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,21 @@ new Promise((resolve, reject) => {
}
})

// adapted from gnome-shell code
const recursivelyDeleteDir = dir => {
const children = dir.enumerate_children('standard::name,standard::type',
Gio.FileQueryInfoFlags.NONE, null)

let info
while (info = children.next_file(null)) {
const type = info.get_file_type()
const child = dir.get_child(info.get_name())
if (type == Gio.FileType.REGULAR) child.delete(null)
else if (type == Gio.FileType.DIRECTORY) recursivelyDeleteDir(child)
}
dir.delete(null)
}

class Storage {
constructor(key, type, indent) {
this.indent = indent
Expand Down Expand Up @@ -1801,7 +1816,7 @@ class BookViewerWindow {
settings.set_boolean('window-maximized', windowMaximized)

if (this._ttsToken) this._ttsToken.interrupt()
if (this._tmpdir) GLib.rmdir(this._tmpdir)
if (this._tmpdir) recursivelyDeleteDir(Gio.File.new_for_path(this._tmpdir))
})

this.activateTheme()
Expand Down

0 comments on commit c3d4b39

Please sign in to comment.