diff --git a/Globals.py b/Globals.py index f110579..935ea7f 100644 --- a/Globals.py +++ b/Globals.py @@ -2,4 +2,4 @@ config_man = ConfigManager() -version_string = '1.2.1' +version_string = '1.2.2' diff --git a/libs/servers/WatchServerOpenTera.py b/libs/servers/WatchServerOpenTera.py index 88473ce..dff87f4 100644 --- a/libs/servers/WatchServerOpenTera.py +++ b/libs/servers/WatchServerOpenTera.py @@ -95,10 +95,20 @@ def new_file_received(self, device_name: str, filename: str): kwargs={'device_name': device_name}) self._device_timeouts[device_name].start() + def new_file_received(self, device_name: str, filename: str): + # Cancel sync timer on new file + if self.file_syncher_timer: + self.file_syncher_timer.cancel() + self.file_syncher_timer = None + def device_disconnected(self, device_name: str): - self.initiate_opentera_transfer(device_name) + # self.initiate_opentera_transfer(device_name) + # Wait 30 seconds after the last disconnected device to start transfer + self.file_syncher_timer = threading.Timer(30, self.sync_files) + self.file_syncher_timer.start() def sync_files(self): + self.file_syncher_timer = None logging.info("WatchServerOpenTera: Checking if any pending transfers...") # Get base folder path base_folder = os.path.join(self.data_path, 'ToProcess') diff --git a/libs/servers/handlers/BaseAppleWatchRequestHandler.py b/libs/servers/handlers/BaseAppleWatchRequestHandler.py index 05e8846..a0e7b92 100644 --- a/libs/servers/handlers/BaseAppleWatchRequestHandler.py +++ b/libs/servers/handlers/BaseAppleWatchRequestHandler.py @@ -88,14 +88,14 @@ def do_POST(self): # Supported file type? if file_type.lower() in ['data', 'dat', 'csv', 'txt', 'oimi']: - if file_type.lower() in ['data', 'dat']: - # Binary file - fh = open(destination_path, 'wb') - text_format = False - else: - # Text file - fh = open(destination_path, 'w') - text_format = True + # if file_type.lower() in ['data', 'dat']: + # Binary file + fh = open(destination_path, 'wb') + # text_format = False + # else: + # Text file + # fh = open(destination_path, 'w') + # text_format = True while content_size_remaining > 0: if buffer_size > content_size_remaining: @@ -110,19 +110,11 @@ def do_POST(self): str(err_desc)) return - if text_format: - fh.write(data.decode(errors="ignore")) # Ignore unknown characters and errors - else: - fh.write(data) + # if text_format: + # fh.write(data.decode(errors="ignore")) # Ignore unknown characters and errors + # else: + fh.write(data) content_size_remaining -= buffer_size - # content_received = (content_length - content_size_remaining) - # pc = math.floor((content_received / content_length) * 100) - # if pc != last_pc: - # self.streamer.update_progress.emit(file_name, " (" + str(content_received) + "/ " + - # str(content_length) + ")", (content_length - - # content_size_remaining), - # content_length) - # last_pc = pc fh.close() else: # self.streamer.add_log.emit(device_name + ": " + file_name + " - Type de fichier non-supporté: " +