From aac333a6d483fea0a12303f2f8147d09f6350d6f Mon Sep 17 00:00:00 2001 From: Arthur Date: Tue, 6 May 2025 11:50:02 -0700 Subject: [PATCH] 19381 fix data file script sync --- netbox/core/models/files.py | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/netbox/core/models/files.py b/netbox/core/models/files.py index d60269b8b..9af20b484 100644 --- a/netbox/core/models/files.py +++ b/netbox/core/models/files.py @@ -88,19 +88,11 @@ class ManagedFile(SyncedDataMixin, models.Model): def sync_data(self): if self.data_file: self.file_path = os.path.basename(self.data_path) - self._write_to_disk(self.full_path, overwrite=True) - def _write_to_disk(self, path, overwrite=False): - """ - Write the object's data to disk at the specified path - """ - # Check whether file already exists - storage = self.storage - if storage.exists(path) and not overwrite: - raise FileExistsError() + storage = self.storage - with storage.open(path, 'wb+') as new_file: - new_file.write(self.data) + with storage.open(self.full_path, 'wb+') as new_file: + new_file.write(self.data_file.data) @cached_property def storage(self):