Skip to content

Commit 04ca8b3

Browse files
committed
adding behaviour so total number of existing files is retained and does not change with the decorator
1 parent 1433d0a commit 04ca8b3

File tree

4 files changed

+15
-8
lines changed

4 files changed

+15
-8
lines changed

rfi_file_monitor/engines/file_watchdog_engine.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,13 +146,17 @@ def _search_for_existing_files(self, directory: Path) -> List[RegularFile]:
146146
FileStatus.SAVED,
147147
)
148148
rv.append(_file)
149+
GLib.idle_add(
150+
self._engine._appwindow._queue_manager.get_total_files_in_path,
151+
len(rv),
152+
priority=GLib.PRIORITY_DEFAULT_IDLE,
153+
)
149154

150155
return rv
151156

152157
@do_bulk_upload
153158
def process_existing_files(self, existing_files):
154159
try:
155-
156160
GLib.idle_add(
157161
self._engine._appwindow._queue_manager.add,
158162
existing_files,

rfi_file_monitor/queue_manager.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ def __init__(self, appwindow):
3838
self._files_dict: OrderedDictType[str, File] = OrderedDict()
3939
self._jobs_list: Final[List[Job]] = list()
4040
self._njobs_running: int = 0
41+
self._total_files_in_path: int = 0
4142

4243
kwargs = dict(
4344
halign=Gtk.Align.FILL,
@@ -453,6 +454,9 @@ def stop(self):
453454
self._running = False
454455
self.notify("running")
455456

457+
def get_total_files_in_path(self, number_of_files: int):
458+
self._total_files_in_path = number_of_files
459+
456460
def _files_dict_timeout_cb(self, *user_data):
457461
"""
458462
This function runs every second, and will take action based on the status of all files in the dict
@@ -563,7 +567,7 @@ def _files_dict_timeout_cb(self, *user_data):
563567
# update status bar
564568
self._appwindow._status_grid.get_child_at(
565569
0, 0
566-
).props.label = f"Total: {len(self._files_dict)}"
570+
).props.label = f"Total: {self._total_files_in_path }"
567571
for _status, _counter in status_counters.items():
568572
self._appwindow._status_grid.get_child_at(
569573
int(_status), 0

rfi_file_monitor/utils/decorators.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,13 +210,12 @@ def wrapper(self: Engine, existing_files: List):
210210
n = 1
211211
processed_files = 0
212212
for rv in chunked_input:
213-
chunk_weight = sum(
214-
[Path(file.filename).stat().st_size for file in rv]
215-
)
213+
# chunk_weight = sum(
214+
# [Path(file.filename).stat().st_size for file in rv]
215+
# )
216216
process_existing_files(self, rv)
217217

218-
while processed_files < chunk_size*n*0.9: # refresh the list when we are at 90% of the size
219-
j = 0
218+
while processed_files < chunk_size*n*0.9: # refresh the list when we are at 90% of the size
220219
processed_files = sum([
221220
item
222221
for item in self._engine._appwindow._queue_manager._files_dict.values()

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ rfi_file_monitor.files =
6565
WeightedRegularFile = rfi_file_monitor.files.regular_file:WeightedRegularFile
6666
S3Object = rfi_file_monitor.files.s3_object:S3Object
6767
Directory = rfi_file_monitor.files.directory:Directory
68-
gui_scripts =
68+
console_scripts =
6969
rfi-file-monitor = rfi_file_monitor:main
7070

7171
[bdist_wheel]

0 commit comments

Comments
 (0)