Skip to content

Conversation

@artembilan
Copy link
Member

Fixes: #10162

The AbstractPersistentAcceptOnceFileListFilter may cause a problem with entries in the MetadataStore when the same file name is used from different directories. Let's imagine a scenario when remote directories are created every day with respective timestamp, e.g. today 20250828, tomorrow 20250829.
The files in those directories are based on customer names: customer1.xml, customer2.xml etc.
Since most of the AbstractPersistentAcceptOnceFileListFilter implementations do just something like this: return file.getName(); that would lead to the same key for the MetadataStore operations.

  • Fix SmbPersistentAcceptOnceFileListFilter to use SmbFile.getUncPath() as a notation of the full path file
  • Fix SftpPersistentAcceptOnceFileListFilter to use SftpClient.DirEntry.getLongFilename() if it is not empty.
  • Fix SftpSession.list() to populated the mentioned longFileName into a new SftpClient.DirEntry instance based on just fetched
  • Introduce an EnhancedFTPFile adapter to delegate to the original FTPFile and populate an additional longFileName property
  • Check for this new class in the FtpPersistentAcceptOnceFileListFilter to extract its longFileName property

…FileListFilter`

Fixes: spring-projects#10162

The `AbstractPersistentAcceptOnceFileListFilter` may cause a problem with entries
in the `MetadataStore` when the same file name is used from different directories.
Let's imagine a scenario when remote directories are created every day with respective timestamp,
e.g. today `20250828`, tomorrow `20250829`.
 The files in those directories are based on customer names: `customer1.xml`, `customer2.xml` etc.
Since most of the `AbstractPersistentAcceptOnceFileListFilter` implementations do just something like this:
`return file.getName();` that would lead to the same key for the `MetadataStore` operations.

* Fix `SmbPersistentAcceptOnceFileListFilter` to use `SmbFile.getUncPath()` as a notation of the full path file
* Fix `SftpPersistentAcceptOnceFileListFilter` to use `SftpClient.DirEntry.getLongFilename()` if it is not empty.
* Fix `SftpSession.list()` to populated the mentioned `longFileName` into a new `SftpClient.DirEntry` instance based on just fetched
* Introduce an `EnhancedFTPFile` adapter to delegate to the original `FTPFile` and populate an additional `longFileName` property
* Check for this new class in the `FtpPersistentAcceptOnceFileListFilter` to extract its `longFileName` property
@artembilan artembilan requested a review from cppwfs September 15, 2025 17:47
Copy link
Contributor

@cppwfs cppwfs left a comment

Choose a reason for hiding this comment

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

Looks great! Just my usual nitpicks!

* Improve `FtpSession.list()` to use a new array instead of `LinkedList`
* Also, use `.` as a working directory placeholder and always populate a long file name
@artembilan artembilan requested a review from cppwfs September 15, 2025 20:02
@cppwfs cppwfs merged commit c7b3cb4 into spring-projects:main Sep 15, 2025
3 checks passed
@cppwfs
Copy link
Contributor

cppwfs commented Sep 15, 2025

LGTM. Thanks for working on this. It's awesome!

@artembilan artembilan deleted the GH-10162 branch September 15, 2025 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The AbstractPersistentAcceptOnceFileListFilter does not deal with full file name

2 participants