Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion metaflow/plugins/datastores/local_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def save_bytes(self, path_and_bytes_iter, overwrite=False, len_hint=0):
else:
byte_obj, metadata = obj, None
full_path = self.full_uri(path)
if not overwrite and os.path.exists(full_path):
if overwrite and os.path.exists(full_path):
continue
Comment on lines +138 to 139

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P0 The guard condition has been inverted, breaking the semantics of the overwrite parameter entirely. With this change, when overwrite=True (caller explicitly wants to replace an existing file) the function now skips the write and does nothing. Conversely, when overwrite=False (the default, meaning "don't replace existing files") the continue is never reached and every existing file gets silently overwritten. The base-class docstring in datastore_storage.py is clear: overwrite=False must leave existing objects untouched. Removing the not reverses both cases simultaneously.

Suggested change
if overwrite and os.path.exists(full_path):
continue
if not overwrite and os.path.exists(full_path):
continue

LocalStorage._makedirs(os.path.dirname(full_path))
self._atomic_write(full_path, byte_obj.read(), mode="wb")
Expand Down