Skip to content

Commit 6054f81

Browse files
authored
Merge pull request #19418 from netbox-community/19381-script
19381 fix data file script sync
2 parents fc98294 + aac333a commit 6054f81

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

netbox/core/models/files.py

+3-11
Original file line numberDiff line numberDiff line change
@@ -88,19 +88,11 @@ def _resolve_root_path(self):
8888
def sync_data(self):
8989
if self.data_file:
9090
self.file_path = os.path.basename(self.data_path)
91-
self._write_to_disk(self.full_path, overwrite=True)
9291

93-
def _write_to_disk(self, path, overwrite=False):
94-
"""
95-
Write the object's data to disk at the specified path
96-
"""
97-
# Check whether file already exists
98-
storage = self.storage
99-
if storage.exists(path) and not overwrite:
100-
raise FileExistsError()
92+
storage = self.storage
10193

102-
with storage.open(path, 'wb+') as new_file:
103-
new_file.write(self.data)
94+
with storage.open(self.full_path, 'wb+') as new_file:
95+
new_file.write(self.data_file.data)
10496

10597
@cached_property
10698
def storage(self):

0 commit comments

Comments
 (0)