Skip to content

[18.0][IMP] fs_storage: add _move_file helper#606

Open
ArnauCForgeFlow wants to merge 1 commit into
OCA:18.0from
ForgeFlow:18.0-imp-fs_storage-add_move_file_method
Open

[18.0][IMP] fs_storage: add _move_file helper#606
ArnauCForgeFlow wants to merge 1 commit into
OCA:18.0from
ForgeFlow:18.0-imp-fs_storage-add_move_file_method

Conversation

@ArnauCForgeFlow
Copy link
Copy Markdown

Add a generic _move_file helper on fs.storage: checks that the source file exists and schedules fs.move as a post-commit hook so the storage stays in sync with the DB transaction.

@simahawk
Copy link
Copy Markdown
Contributor

Build fixed here #603

@ArnauCForgeFlow
Copy link
Copy Markdown
Author

Rebased @simahawk

Copy link
Copy Markdown
Contributor

@LoisRForgeFlow LoisRForgeFlow left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Copy Markdown
Contributor

@simahawk simahawk left a comment

Choose a reason for hiding this comment

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

would be nice to have some test cov

Comment thread fs_storage/models/fs_storage.py Outdated
@ArnauCForgeFlow ArnauCForgeFlow force-pushed the 18.0-imp-fs_storage-add_move_file_method branch from 5e87199 to 4726811 Compare May 21, 2026 12:41
@ArnauCForgeFlow
Copy link
Copy Markdown
Author

@simahawk added tests

@ArnauCForgeFlow
Copy link
Copy Markdown
Author

can we merge? @simahawk

@OCA-git-bot
Copy link
Copy Markdown
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

if not self.fs.exists(src):
return False
dst = (PurePath(to_dir_str) / filename).as_posix()
self.env.cr.postcommit.add(functools.partial(self.fs.move, src, dst))
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.

The intent of the fs_storage library is to provide access to an fsspec proxy client instance based on a configured storage backend. The original intention was not to build an additional API layer on top of the fsspec API itself.

To me, it feels strange that calling the _move_file method would not actually move the file by the end of the method call.

If the goal is to address a transactional consistency issue — ensuring that modifications made to the external filesystem remain consistent with the Odoo transaction — then the approach should probably be different, and significantly more complex. (we should rely on the transactional layer of the fsspec library requiring that the different client stubs supports properly the caching mechanism)

In this specific case, you could simply move the file directly within the method and register a rollback hook to move it back if the transaction fails.

So, to be honest, I’m a bit confused by this proposal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants