Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#2181] Redesign FileAPI to use original file name #2300

Closed
wants to merge 14 commits into from

Conversation

muyangye
Copy link
Member

@muyangye muyangye commented Dec 9, 2023

Purpose

Try to fix #2181

Remarks

PR introduces (a) breaking change(s): no

PR introduces (a) deprecation(s): no

After this change, if the users are trying to upload a file that already exists (same original file name ignoring case):
4b6edcdc19237ebba5a6203cb9a101d
They can upload just like before after rename:
4e957bb66de0a8efb109f1836c35acc
Similarly, when users can upload multiple files and some of them already exist:
baf592794791a090bfb4dc1667a54d3
The dialog will keep appearing if even after rename, those files still exist:
9c2b2df4708ab6eff414548cdd208ac
As you may noticed, there are already some files with same name in the background. I created those files before this change to test migration. After the migration, they shall be renamed:
a16442acef371bad4aa52cf7dd69f2b
00e5b52edead535d6fdd30cddd078b6
I have also created adapters using those files and verified they still work (as well as pipelines using those adapters):
032a4cb01e70878cc8682d022a9f6aa
10b2e6666174d825dbf869cf6b4b022

I have not implemented E2E tests for this new feature because the discussion of #2181 is ongoing. If everyone is happy with this solution. I'll go ahead create an issue to implement the E2E tests.

I know the code is a little bit long. So TLDR, I have kept internalFilename and originalFilename to avoid damages to other processes using current files. However, I added an endpoint /allFilenames in PipelineElementFile that fetches all current originalFilenames so that in the frontend I can check if some files users uploaded already exist and if so, let users rename those files. In addition, since before this change, there are probably some files with the same name, I have implemented a DuplicateFilesRenameMigration to rename those files' originalFilename.

@muyangye muyangye requested a review from tenthe December 9, 2023 03:12
@github-actions github-actions bot added java Pull requests that update Java code ui Anything that affects the UI backend Everything that is related to the StreamPipes backend labels Dec 9, 2023
@muyangye muyangye requested a review from bossenti December 9, 2023 03:12
Copy link
Contributor

@bossenti bossenti left a comment

Choose a reason for hiding this comment

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

Thank you very much for this PR and the detailed documentation @muyangye. I really appreciate!
I've left some minor remarks for improvements.

@dominikriemer Can you give the UI changes a review?

}

@Override
public void executeMigration() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be great if you could add some documentation here about why this migration is necessary. So that we easily can relate this migration to it's purpose later on as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's a good suggestion! I'll add some documentation.

muyangye and others added 4 commits December 11, 2023 19:37
…service/core/migrations/v095/DuplicateFilesRenameMigration.java

Co-authored-by: Tim <50115603+bossenti@users.noreply.github.com>
…nt.html

Co-authored-by: Tim <50115603+bossenti@users.noreply.github.com>
…l/PipelineElementFile.java

Co-authored-by: Tim <50115603+bossenti@users.noreply.github.com>
…l/PipelineElementFile.java

Co-authored-by: Tim <50115603+bossenti@users.noreply.github.com>
Copy link
Contributor

@tenthe tenthe left a comment

Choose a reason for hiding this comment

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

Hi @muyangye,
thanks a lot for your PR. I think it's very good.
I have created another branch myself in which I have written a unit test for the DuplicateFilesRenameMigrationTest.executeMigration() method. I also refactored it a bit. What do you think? Do you think this iteration is an improvement? Link to branch

@muyangye
Copy link
Member Author

Hi @muyangye,
thanks a lot for your PR. I think it's very good.
I have created another branch myself in which I have written a unit test for the DuplicateFilesRenameMigrationTest.executeMigration() method. I also refactored it a bit. What do you think? Do you think this iteration is an improvement? Link to branch

Hi @tenthe, thanks a lot for the refactoring! I think those code are much more self-explanatory! Thanks for the unit tests too. I didn’t write unit tests because this migration is a temporary solution. I’ll come up with unit tests for my next PR. Btw I still haven’t added a comment that Tim suggested and I will do that once I land (checking in for a flight right now) :)

@muyangye
Copy link
Member Author

@bossenti @tenthe Sorry for the late reply. I am currently in China and I was trying to solve Github being blocked for the past 2 days and found no luck:
1702962524794
I used a VPN which is needed to even access Github but still couldn't do git push. I just realized I could directly commit on web. Can you merge your branch since I can't do anything with Git @tenthe? Sorry for the inconvenience...

@tenthe tenthe mentioned this pull request Dec 20, 2023
@muyangye
Copy link
Member Author

Closing this PR as updated by #2356.

@muyangye muyangye closed this Dec 24, 2023
tenthe added a commit that referenced this pull request Dec 29, 2023
* Serialize non-primitive types and store in Influx

* extract RawFieldSerializer

* rename test

* delete old

* temp

* redesign file api

* fix

* Update streampipes-service-core/src/main/java/org/apache/streampipes/service/core/migrations/v095/DuplicateFilesRenameMigration.java

Co-authored-by: Tim <50115603+bossenti@users.noreply.github.com>

* Update ui/src/app/files/dialog/file-rename/file-rename-dialog.component.html

Co-authored-by: Tim <50115603+bossenti@users.noreply.github.com>

* Update streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/PipelineElementFile.java

Co-authored-by: Tim <50115603+bossenti@users.noreply.github.com>

* Update streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/PipelineElementFile.java

Co-authored-by: Tim <50115603+bossenti@users.noreply.github.com>

* refactor(#2181): Refactor DuplicateFilesRenameMigration

* Add comment for migration

* fix(#2356): Fix linting error

* fix(#2356): Fix checkstyle proble

---------

Co-authored-by: muyangye <muyangye@usc.edu>
Co-authored-by: Tim <50115603+bossenti@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Everything that is related to the StreamPipes backend java Pull requests that update Java code ui Anything that affects the UI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Redesign FileAPI to use original file name
3 participants