Skip to content

Commit cc9a33b

Browse files
committed
Change a destination of the temp file
1 parent 335d1cf commit cc9a33b

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

src/core/periodic_saving.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from pathlib import Path
44
from gi.repository import GLib, Gio
55
from savedesktop.globals import *
6-
from savedesktop.core.password_store import PasswordStore
76

87
# Get the current date
98
dt = datetime.now()
@@ -33,9 +32,10 @@ def run(self, now: bool) -> None:
3332
self.pbfolder = f'{settings["periodic-saving-folder"].format(download_dir)}'
3433

3534
if now:
36-
print("Saving immediately")
35+
print("MODE: Save now")
3736
self.backup()
3837
else:
38+
print("MODE: Periodic saving")
3939
self.get_interval()
4040

4141
# Get the periodic saving interval from GSettings
@@ -58,7 +58,7 @@ def check_and_backup(self, interval):
5858
print(f"Backup not needed today. Last backup was on {self.last_backup_date}.")
5959

6060
def backup(self):
61-
if self.pbfolder == f'{download_dir}/SaveDesktop/archives':
61+
if self.pbfolder == '{}/SaveDesktop/archives'.format(download_dir) or self.pbfolder == f'{download_dir}/SaveDesktop/archives':
6262
try:
6363
if not os.path.exists(f"{download_dir}/SaveDesktop/archives"):
6464
os.makedirs(f"{download_dir}/SaveDesktop/archives")
@@ -72,7 +72,6 @@ def backup(self):
7272
else:
7373
self.filename = settings["filename-format"]
7474

75-
print("MODE: Periodic saving")
7675
self.call_archive_command()
7776

7877
self.save_last_backup_date()

src/core/synchronization.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@ def try_passwordstore():
132132
app.run([])
133133
self.password = try_passwordstore()
134134

135-
# #3 If password is still unavailable, get it from the {DATA}/entered-password.txt file
136-
if not self.password and os.path.exists(f"{DATA}/entered-password.txt"):
137-
with open(f"{DATA}/entered-password.txt") as ep:
135+
# #3 If password is still unavailable, get it from the {CACHE}/entered-password.txt file
136+
if not self.password and os.path.exists(f"{CACHE}/temp_file"):
137+
with open(f"{CACHE}/temp_file") as ep:
138138
self.password = ep.read().strip()
139139

140140
# #4 Final check
@@ -159,8 +159,8 @@ def done(self):
159159
with open(f"{DATA}/sync-info.json", "w") as s:
160160
json.dump({"last-synced": date.today().isoformat()}, s)
161161

162-
if os.path.exists(f"{DATA}/entered-password.txt"):
163-
os.remove(f"{DATA}/entered-password.txt")
162+
if os.path.exists(f"{CACHE}/temp_file"):
163+
os.remove(f"{CACHE}/temp_file")
164164

165165
# Send a notification about finished synchronization
166166
os.system(f"notify-send 'Save Desktop Synchronization ({self.file})' '{_('The configuration has been applied!')} {_('Changes will only take effect after the next login')}' -i io.github.vikdevelop.SaveDesktop-symbolic")

src/gui/password_checker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def save_password(self, w):
7777
if self.remSwitch.get_active():
7878
PasswordStore(self.passEntry.get_text())
7979
else:
80-
with open(f"{DATA}/entered-password.txt", "w") as ep:
80+
with open(f"{CACHE}/temp_file", "w") as ep:
8181
ep.write(self.passEntry.get_text())
8282
self.close()
8383

0 commit comments

Comments
 (0)