Skip to content

Commit

Permalink
File extension change
Browse files Browse the repository at this point in the history
Varia now uses the ".varia" file extension instead of ".varia.json". The mimeinfo now registers ".varia" files as "Varia Download Progress" and ".aria2" files as "Aria2 Download Progress".
  • Loading branch information
giantpinkrobots committed Sep 23, 2024
1 parent 5c80416 commit 1f0b3f4
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 13 deletions.
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
.vscode
_build
.flatpak-builder
src/__pycache__/
src/download/__pycache__/
src/window/__pycache__/
/src/__pycache__
/src/download/__pycache__
/src/window/__pycache__
7 changes: 6 additions & 1 deletion data/io.github.giantpinkrobots.varia.mime.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
<mime-type type="application/varia">
<comment>Varia Download Progress</comment>
<glob pattern="*.aria2"/>
<glob pattern="*.varia"/>
<generic-icon name="io.github.giantpinkrobots.varia.mime"/>
</mime-type>
<mime-type type="application/aria2">
<comment>Aria2 Download Progress</comment>
<glob pattern="*.aria2"/>
<generic-icon name="text-x-script"/>
</mime-type>
</mime-info>

10 changes: 5 additions & 5 deletions src/download/thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ def run(self):
GLib.idle_add(self.update_labels_and_things)
if ((self.download.is_complete) and (self.download.is_metadata == False)):
print('Download complete: ' + self.download.gid)
if os.path.exists(os.path.join(self.downloaddir,(self.download.gid + ".varia.json"))):
os.remove(os.path.join(self.downloaddir,(self.download.gid + ".varia.json")))
if os.path.exists(os.path.join(self.downloaddir,(self.download.gid + ".varia"))):
os.remove(os.path.join(self.downloaddir,(self.download.gid + ".varia")))
break
elif ((self.download.is_torrent) and (self.download.seeder)):
print('Torrent complete, seeding: ' + self.download.gid)
Expand Down Expand Up @@ -200,8 +200,8 @@ def stop(self, deletefiles):
self.download.remove(force=True)
if not self.download.is_complete:
if (deletefiles == True):
if os.path.exists(os.path.join(self.downloaddir,(downloadgid + ".varia.json"))):
os.remove(os.path.join(self.downloaddir,(downloadgid + ".varia.json")))
if os.path.exists(os.path.join(self.downloaddir,(downloadgid + ".varia"))):
os.remove(os.path.join(self.downloaddir,(downloadgid + ".varia")))
if os.path.exists(os.path.join(self.downloaddir, downloadname)):
os.remove(os.path.join(self.downloaddir, downloadname))
print ("Download stopped.")
Expand All @@ -220,7 +220,7 @@ def save_state(self):
'url': self.url,
'filename': self.download.name
}
with open(os.path.join(self.downloaddir, f'{self.download.gid}.varia.json'), 'w') as f:
with open(os.path.join(self.downloaddir, f'{self.download.gid}.varia'), 'w') as f:
json.dump(state, f)
print ("State saved for download.")

Expand Down
13 changes: 9 additions & 4 deletions src/variamain.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,19 @@ def __init__(self, variaapp, appdir, appconf, aria2c_subprocess, aria2cexec, *ar
default_state = {"url": None, "filename": None}

for filename in os.listdir(self.appconf["download_directory"]):
if filename.endswith('.varia.json'):

with open(os.path.join(self.appconf["download_directory"], filename), 'r') as f:
if (filename.endswith('.varia.json')) or (filename.endswith('.varia')):
if (filename.endswith(".varia.json")):
current_filename = filename.replace(".json", "")
os.rename(os.path.join(self.appconf["download_directory"], filename), os.path.join(self.appconf["download_directory"], current_filename))
else:
current_filename = filename

with open(os.path.join(self.appconf["download_directory"], current_filename), 'r') as f:
loaded_state = json.load(f)

state = {**default_state, **loaded_state}
objectlist = create_actionrow(self, state['url'])
download_thread = DownloadThread.load_state(self, filename, state['url'], objectlist[0], objectlist[1], objectlist[2], objectlist[3], objectlist[4], None, state['filename'])
download_thread = DownloadThread.load_state(self, current_filename, state['url'], objectlist[0], objectlist[1], objectlist[2], objectlist[3], objectlist[4], None, state['filename'])
self.downloads.append(download_thread)
download_thread.start()

Expand Down

0 comments on commit 1f0b3f4

Please sign in to comment.