Merge pull request #16783 from SergeyYakubov/get-rid-of-filename-property

Replace file_name property with get_file_name function
This commit is contained in:
John Davis
2023-11-08 17:19:40 -05:00
committed by GitHub
97 changed files with 517 additions and 480 deletions
+9 -9
View File
@@ -599,13 +599,13 @@ def _delete_dataset(dataset, app, remove_from_disk, info_only=False, is_deletabl
)
if remove_from_disk:
try:
log.info("Removing disk file %s", metadata_file.file_name)
os.unlink(metadata_file.file_name)
log.info("Removing disk file %s", metadata_file.get_file_name())
os.unlink(metadata_file.get_file_name())
except Exception as e:
log.info(
"Error, exception: %s caught attempting to purge metadata file %s\n",
unicodify(e),
metadata_file.file_name,
metadata_file.get_file_name(),
)
metadata_file.purged = True
app.sa_session.add(metadata_file)
@@ -615,7 +615,7 @@ def _delete_dataset(dataset, app, remove_from_disk, info_only=False, is_deletabl
app.sa_session.add(metadata_file)
with transaction(session):
session.commit()
log.info(metadata_file.file_name)
log.info(metadata_file.get_file_name())
if not info_only:
log.info("Deleting dataset id %d", dataset.id)
dataset.deleted = True
@@ -635,8 +635,8 @@ def _purge_dataset(app, dataset, remove_from_disk, info_only=False):
# Remove files from disk and update the database
if remove_from_disk:
# TODO: should permissions on the dataset be deleted here?
log.info("Removing disk, file %s", dataset.file_name)
os.unlink(dataset.file_name)
log.info("Removing disk, file %s", dataset.get_file_name())
os.unlink(dataset.get_file_name())
# Remove associated extra files from disk if they exist
if dataset.extra_files_path and os.path.exists(dataset.extra_files_path):
shutil.rmtree(
@@ -662,7 +662,7 @@ def _purge_dataset(app, dataset, remove_from_disk, info_only=False):
log.info(
"This dataset (%d) is not purgable, the file (%s) will not be removed.\n",
dataset.id,
dataset.file_name,
dataset.get_file_name(),
)
except OSError as exc:
log.error("Error, dataset file has already been removed: %s", unicodify(exc))
@@ -674,9 +674,9 @@ def _purge_dataset(app, dataset, remove_from_disk, info_only=False):
except ObjectNotFound:
log.error("Dataset %d cannot be found in the object store", dataset.id)
except Exception as exc:
log.error("Error attempting to purge data file: %s error: %s", dataset.file_name, unicodify(exc))
log.error("Error attempting to purge data file: %s error: %s", dataset.get_file_name(), unicodify(exc))
else:
log.info("Error: '%s' has not previously been deleted, so it cannot be purged\n", dataset.file_name)
log.info("Error: '%s' has not previously been deleted, so it cannot be purged\n", dataset.get_file_name())
def _purge_folder(folder, app, remove_from_disk, info_only=False):
+2 -2
View File
@@ -44,7 +44,7 @@ if args.hda_id:
except Exception:
hda_id = int(helper.decode_id(args.hda_id))
hda = model.session.get(model.HistoryDatasetAssociation, hda_id)
print(f'HDA "{hda.id}" is Dataset "{hda.dataset.id}" at: {hda.file_name}')
print(f'HDA "{hda.id}" is Dataset "{hda.dataset.id}" at: {hda.get_file_name()}')
if args.ldda_id:
try:
@@ -52,4 +52,4 @@ if args.ldda_id:
except Exception:
ldda_id = int(helper.decode_id(args.ldda_id))
ldda = model.session.get(model.LibraryDatasetDatasetAssociation, ldda_id)
print(f'LDDA "{ldda.id}" is Dataset "{ldda.dataset.id}" at: {ldda.file_name}')
print(f'LDDA "{ldda.id}" is Dataset "{ldda.dataset.id}" at: {ldda.get_file_name()}')