Skip to content

Commit f834535

Browse files
authored
Update synchronization.py
1 parent 010022b commit f834535

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/synchronization.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,15 @@ def extract_archive(self):
139139
print("No errors with getting a password detected.")
140140
try:
141141
if os.path.exists(f"{settings['file-for-syncing']}/{self.file}.sd.zip"):
142-
with zipfile.ZipFile(f"{settings['file-for-syncing']}/{self.file}.sd.zip", "r") as zip_ar:
143-
for member in zip_ar.namelist():
144-
if self.password != None:
145-
zip_ar.extract(member, path=f"{CACHE}/syncing", pwd=self.password.encode("utf-8"))
146-
else:
147-
zip_ar.extract(member, path=f"{CACHE}/syncing")
142+
try:
143+
result = subprocess.run(
144+
['7z', 'x', f'-p{self.password}', f"{settings['file-for-syncing']}/{self.file}.sd.zip", f'-o{CACHE}/syncing', '-y'],
145+
capture_output=True, text=True, check=True
146+
)
147+
print("Output:", result.stdout)
148+
except subprocess.CalledProcessError as e:
149+
print("Return code:", e.returncode)
150+
raise OSError(e.stderr)
148151
else:
149152
with tarfile.open(f"{settings['file-for-syncing']}/{self.file}.sd.tar.gz", 'r:gz') as tar:
150153
for member in tar.getmembers():

0 commit comments

Comments
 (0)