Skip to content

Commit 29ebe7d

Browse files
committed
enh: warn user about too many resources in a dataset (close #86)
1 parent 3da89bd commit 29ebe7d

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
0.17.2
22
- fix: check for existence of DC resources before starting uploads (#85)
33
- enh: sort resources according to internal basin dependencies (#79)
4+
- enh: warn user about too many resources in a dataset (#86)
45
- ref: use more f-strings
56
- ref: add `common.is_dc_file` for consistent resource checks
67
0.17.1

dcoraid/gui/upload/dlg_upload.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def __init__(self, *args, **kwargs):
121121
# do not allow to proceed without a title
122122
self.lineEdit_authors.textChanged.connect(self.on_authors_edited)
123123
self.on_authors_edited("") # initial state
124-
# if the user changes the preset combobox text, offer him
124+
# if the user changes the preset combobox text, offer them
125125
# to save it as a preset
126126
self.comboBox_preset.editTextChanged.connect(
127127
self.on_preset_text_edited)
@@ -314,6 +314,24 @@ def on_proceed(self):
314314
"resource.")
315315
return
316316

317+
# If the user uploads A LOT of resources in a dataset, we should
318+
# warn them about possible performance penalties.
319+
max_num_res = 100
320+
if len(paths) > max_num_res:
321+
choice = QtWidgets.QMessageBox.question(
322+
self, "Unusually large number of resources specified",
323+
f"You are attempting to upload {len(paths)} resources "
324+
f"in one single dataset. Be advised that adding more than "
325+
f"{max_num_res} resources to a dataset might affect DCOR "
326+
f"performance (listing the resources can be slow).\n\n"
327+
f"Too many resources in one dataset may also impair the "
328+
f"ability of a human to grasp what you are attempting to "
329+
f"share.\n\n"
330+
f"Are you sure you want to upload {len(paths)} resources to "
331+
f"this dataset? Select 'Yes' to continue with the upload.")
332+
if choice != QtWidgets.QMessageBox.StandardButton.Yes:
333+
return
334+
317335
# Checking for duplicate resources is the responsibility of
318336
# DCOR-Aid, because we are skipping existing resources in
319337
# dcoraid.upload.job.UploadJob.task_upload_resources.

0 commit comments

Comments
 (0)