Bug 40811

Summary: Enhance Koha::File::Transport API
Product: Koha Reporter: Tomás Cohen Arazi (tcohen) <tomascohen>
Component: Architecture, internals, and plumbingAssignee: Bugs List <koha-bugs>
Status: In Discussion --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: dcook, jake.deery, martin.renvoize, tomascohen
Version: Main   
Hardware: All   
OS: All   
GIT URL: Change sponsored?: ---
Patch complexity: --- Documentation contact:
Documentation submission: Text to go in the release notes:
Version(s) released in:
Circulation function:
Bug Depends on: 38115    
Bug Blocks:    

Description Tomás Cohen Arazi (tcohen) 2025-09-15 15:22:37 UTC
Looking at bug 38115, it feels like the code that is required to use a transport is too protocol dependent.

The current sequence is:

1) Initialize the transport (->find)
2) Attempt to connect
3) Retrieve the configured base path ($file_server->upload_diectory)
4) Manually set the working dir for uploading $file_server->change_directory)
5) Upload the file

I believe we should (keeping only this FTP/SFTP use case in mind) simplify to:

1) Initialize (->find)
2) Upload the file with an optional path parameter

Step (2) would attempt to connect if the connection is not active, set the path to the passed path or internally pick the default and use it. Any failed step should raise a specific exception.

This schema could work for other protocols like S3, etc.