Removed _tmp_file code that's no longer needed
This commit is contained in:
@@ -85,10 +85,6 @@ class PhotosDB:
|
|||||||
# Dict with information about all the volumes/photos by uuid
|
# Dict with information about all the volumes/photos by uuid
|
||||||
self._dbvolumes = {}
|
self._dbvolumes = {}
|
||||||
|
|
||||||
# list of temporary files created so we can clean them up later
|
|
||||||
# TODO: remove this, don't think it's needed with switch to TemporaryDirectory
|
|
||||||
self._tmp_files = []
|
|
||||||
|
|
||||||
if _debug():
|
if _debug():
|
||||||
logging.debug(f"dbfile = {dbfile}")
|
logging.debug(f"dbfile = {dbfile}")
|
||||||
|
|
||||||
@@ -301,28 +297,23 @@ class PhotosDB:
|
|||||||
|
|
||||||
def _copy_db_file(self, fname):
|
def _copy_db_file(self, fname):
|
||||||
""" copies the sqlite database file to a temp file """
|
""" copies the sqlite database file to a temp file """
|
||||||
""" returns the name of the temp file and appends name to self->_tmp_files """
|
""" returns the name of the temp file """
|
||||||
""" If sqlite shared memory and write-ahead log files exist, those are copied too """
|
""" If sqlite shared memory and write-ahead log files exist, those are copied too """
|
||||||
# required because python's sqlite3 implementation can't read a locked file
|
# required because python's sqlite3 implementation can't read a locked file
|
||||||
_, suffix = os.path.splitext(fname)
|
_, suffix = os.path.splitext(fname)
|
||||||
tmp_files = []
|
|
||||||
try:
|
try:
|
||||||
dest_name = pathlib.Path(fname).name
|
dest_name = pathlib.Path(fname).name
|
||||||
dest_path = os.path.join(self._tempdir_name, dest_name)
|
dest_path = os.path.join(self._tempdir_name, dest_name)
|
||||||
copyfile(fname, dest_path)
|
copyfile(fname, dest_path)
|
||||||
tmp_files.append(dest_path)
|
|
||||||
# copy write-ahead log and shared memory files (-wal and -shm) files if they exist
|
# copy write-ahead log and shared memory files (-wal and -shm) files if they exist
|
||||||
if os.path.exists(f"{fname}-wal"):
|
if os.path.exists(f"{fname}-wal"):
|
||||||
copyfile(f"{fname}-wal", f"{dest_path}-wal")
|
copyfile(f"{fname}-wal", f"{dest_path}-wal")
|
||||||
tmp_files.append(f"{dest_path}-wal")
|
|
||||||
if os.path.exists(f"{fname}-shm"):
|
if os.path.exists(f"{fname}-shm"):
|
||||||
copyfile(f"{fname}-shm", f"{dest_path}-shm")
|
copyfile(f"{fname}-shm", f"{dest_path}-shm")
|
||||||
tmp_files.append(f"{dest_path}-shm")
|
|
||||||
except:
|
except:
|
||||||
print("Error copying " + fname + " to " + dest_path, file=sys.stderr)
|
print("Error copying " + fname + " to " + dest_path, file=sys.stderr)
|
||||||
raise Exception
|
raise Exception
|
||||||
|
|
||||||
self._tmp_files.extend(tmp_files)
|
|
||||||
if _debug():
|
if _debug():
|
||||||
logging.debug(self._dest_path)
|
logging.debug(self._dest_path)
|
||||||
|
|
||||||
@@ -343,7 +334,6 @@ class PhotosDB:
|
|||||||
version = None
|
version = None
|
||||||
|
|
||||||
(conn, c) = self._open_sql_file(self._tmp_db)
|
(conn, c) = self._open_sql_file(self._tmp_db)
|
||||||
# (conn, c) = self._open_sql_file(self._dbfile)
|
|
||||||
|
|
||||||
# get database version
|
# get database version
|
||||||
c.execute(
|
c.execute(
|
||||||
|
|||||||
@@ -765,7 +765,7 @@ def test_photosdb_repr():
|
|||||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||||
photosdb2 = eval(repr(photosdb))
|
photosdb2 = eval(repr(photosdb))
|
||||||
|
|
||||||
ignore_keys = ["_tmp_db", "_tmp_files", "_tempdir", "_tempdir_name"]
|
ignore_keys = ["_tmp_db", "_tempdir", "_tempdir_name"]
|
||||||
assert {k: v for k, v in photosdb.__dict__.items() if k not in ignore_keys} == {
|
assert {k: v for k, v in photosdb.__dict__.items() if k not in ignore_keys} == {
|
||||||
k: v for k, v in photosdb2.__dict__.items() if k not in ignore_keys
|
k: v for k, v in photosdb2.__dict__.items() if k not in ignore_keys
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -336,7 +336,7 @@ def test_photosdb_repr():
|
|||||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||||
photosdb2 = eval(repr(photosdb))
|
photosdb2 = eval(repr(photosdb))
|
||||||
|
|
||||||
ignore_keys = ["_tmp_db", "_tmp_files", "_tempdir", "_tempdir_name"]
|
ignore_keys = ["_tmp_db", "_tempdir", "_tempdir_name"]
|
||||||
assert {k: v for k, v in photosdb.__dict__.items() if k not in ignore_keys} == {
|
assert {k: v for k, v in photosdb.__dict__.items() if k not in ignore_keys} == {
|
||||||
k: v for k, v in photosdb2.__dict__.items() if k not in ignore_keys
|
k: v for k, v in photosdb2.__dict__.items() if k not in ignore_keys
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user