Skip to content

Commit 826f408

Browse files
committed
Fix os._exit(1) preventing normal cleanup
1 parent a654dd5 commit 826f408

File tree

3 files changed

+44
-45
lines changed

3 files changed

+44
-45
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ packages = ["pywaybackup"]
77

88
[project]
99
name = "pywaybackup"
10-
version = "3.4.0"
10+
version = "3.4.1"
1111
description = "Query and download archive.org as simple as possible."
1212
authors = [
1313
{ name = "bitdruid", email = "[email protected]" }

pywaybackup/PyWaybackup.py renamed to pywaybackup/PyWayBackup.py

Lines changed: 42 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -190,46 +190,45 @@ def run(self):
190190

191191
if self.save:
192192
archive_save.save_page(self.url)
193-
os._exit(1)
194-
195-
db.init(self.dbfile, self.query_identifier)
196-
sc.init(self.mode)
197-
198-
if not self.save:
199-
archive_download.startup()
200-
201-
try:
202-
archive_download.query_list(
203-
self.csvfile,
204-
self.cdxfile,
205-
self.range,
206-
self.limit,
207-
self.start,
208-
self.end,
209-
self.explicit,
210-
self.filetype,
211-
self.statuscode,
212-
self.domain,
213-
self.subdir,
214-
self.filename,
215-
)
216-
archive_download.download_list(self.output, self.retry, self.no_redirect, self.delay, self.workers)
217-
except KeyboardInterrupt:
218-
print("\nInterrupted by user\n")
219-
self.keep = True
220-
signal.signal(signal.SIGINT, signal.SIG_IGN)
221-
222-
except Exception as e:
223-
self.keep = True
224-
ex.exception(message="", e=e)
225-
226-
finally:
227-
sc.csv_create(self.csvfile)
228-
sc.fini()
229-
vb.fini()
230-
231-
if not self.keep:
232-
os.remove(self.dbfile) if os.path.exists(self.dbfile) else None
233-
os.remove(self.cdxfile) if os.path.exists(self.cdxfile) else None
234-
235-
os._exit(1)
193+
194+
else:
195+
196+
db.init(self.dbfile, self.query_identifier)
197+
sc.init(self.mode)
198+
199+
if not self.save:
200+
archive_download.startup()
201+
202+
try:
203+
archive_download.query_list(
204+
self.csvfile,
205+
self.cdxfile,
206+
self.range,
207+
self.limit,
208+
self.start,
209+
self.end,
210+
self.explicit,
211+
self.filetype,
212+
self.statuscode,
213+
self.domain,
214+
self.subdir,
215+
self.filename,
216+
)
217+
archive_download.download_list(self.output, self.retry, self.no_redirect, self.delay, self.workers)
218+
except KeyboardInterrupt:
219+
print("\nInterrupted by user\n")
220+
self.keep = True
221+
signal.signal(signal.SIGINT, signal.SIG_IGN)
222+
223+
except Exception as e:
224+
self.keep = True
225+
ex.exception(message="", e=e)
226+
227+
finally:
228+
sc.csv_create(self.csvfile)
229+
sc.fini()
230+
vb.fini()
231+
232+
if not self.keep:
233+
os.remove(self.dbfile) if os.path.exists(self.dbfile) else None
234+
os.remove(self.cdxfile) if os.path.exists(self.cdxfile) else None

pywaybackup/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
from .PyWaybackup import PyWayBackup
1+
from .PyWayBackup import PyWayBackup

0 commit comments

Comments
 (0)