Shuffle icon indicating copy to clipboard operation
Shuffle copied to clipboard

Fix Editing file on web ui

Open FranciscoJavierPizarro opened this issue 2 years ago • 33 comments

The bug Using the web interface of Shuffle, in the admin page, more specific in the files section. When you edit a file that is already defined, and you save it, the contents of this same file duplicate

For example if you have

A
B
C

And you delete C, the new saved file looks like

A
B
C
A
B

To Reproduce Steps to reproduce the behavior:

  1. Open Shuffle website and go to the admin page
  2. Import a file
  3. Edit the file contents on that same interface
  4. Save the file
  5. Check the file contents in that same interface or by using a shuffle tools with get file option

Expected behavior To edit the file as expected without duplicating the contents

FranciscoJavierPizarro avatar Jul 28 '23 08:07 FranciscoJavierPizarro

Ah, so it is appending to the file rather than editing..? I think we fixed something like that a while back, and I confirmed it doesn't happen on the latest version.

What version are you on? Check docker-compose :)

frikky avatar Jul 28 '23 11:07 frikky

Ups sorry if its my bad, i am using the latest, but it had been deployed with the same docker base image since 7 weeks ago, i will test as soon as possible with a test VM with a fresh installation to close this issue if thats the case, thank you

FranciscoJavierPizarro avatar Jul 28 '23 11:07 FranciscoJavierPizarro

Update i had tried the same with a fresh out of the box deployment and it stills happens.

The exact bug is the following, when you modify the file and save it via web UI, it saves the previous content on top, appending to the end the new content

So for example we have this file

A
B

then we edit it on the web so it looks like this

A
B
C

then after saving that when we open again the same file to edit it again we get that the content is this

A
B
A
B
C

The exact deployment is using the docker compose with a fresh clone of the github repo over new VMs.

The only special feature about this deployment apart of being on premmise, is the use of a opensearch cluster instead of a single instance of opensearch.

FranciscoJavierPizarro avatar Jul 28 '23 13:07 FranciscoJavierPizarro

Update i had tried the same with a fresh out of the box deployment and it stills happens.

The exact bug is the following, when you modify the file and save it via web UI, it saves the previous content on top, appending to the end the new content

So for example we have this file

A
B

then we edit it on the web so it looks like this

A
B
C

then after saving that when we open again the same file to edit it again we get that the content is this

A
B
A
B
C

The exact deployment is using the docker compose with a fresh clone of the github repo over new VMs.

The only special feature about this deployment apart of being on premmise, is the use of a opensearch cluster instead of a single instance of opensearch.

Cheers. Looks like it's a problem in latest, but not our nightly builds :)

frikky avatar Jul 28 '23 13:07 frikky

can you help me in locating this?

devharsh2k4 avatar Nov 02 '23 18:11 devharsh2k4

can you help me in locating this?

Hey!

This is in the "Files" UI in the Admin area.

Here's the file: https://github.com/Shuffle/Shuffle/blob/main/frontend/src/components/Files.jsx

frikky avatar Nov 02 '23 22:11 frikky

Hi , i tried to reproduce but after uploading the file edit button is disabled

zZedx avatar Nov 03 '23 08:11 zZedx

I was able to reproduce this issue, will try to see what's causing it.

PratyushChauhan avatar Nov 03 '23 12:11 PratyushChauhan

This bug happens even when the submit button is just clicked without any changes to the file. For example, if the file is

A
B
C

At first, after clicking on the edit button and then the submit button the file changed to

A
B
CA
B
C

I found that the frontend sends the correct request to the backend and it's a problem with the backend. Looking at the API code for HandleEditFile, I found that the problem is with uploadFile function where it opens the file in append mode (os.O_APPEND). See https://github.com/Shuffle/shuffle-shared/blob/f35718eb25d90afef765a76b007bf23c16337839/files.go#L1176. If os.O_APPEND is removed the bug seems to be fixed. Something like the below patch can be done.

diff --git a/files.go b/files.go
index 8427940..728aecb 100755
--- a/files.go
+++ b/files.go
@@ -1173,7 +1173,7 @@ func uploadFile(ctx context.Context, file *File, encryptionKey string, contents
                } else if file.StorageArea == "s3" {
                        log.Printf("SHOULD UPLOAD TO S3!")
                } else {
-                       f, err := os.OpenFile(file.DownloadPath, os.O_CREATE|os.O_WRONLY|os.O_APPEND, os.ModePerm)
+                       f, err := os.OpenFile(file.DownloadPath, os.O_CREATE|os.O_RDWR|os.O_TRUNC, os.ModePerm)

                        if err != nil {
                                // Rolling back file

I'm not familiar with Golang so I'm not sure whether it's right, though local testing tells that it works as expected. I can make a PR if that looks right.

Actually, I've come to this issue because of an assignment for Octernship (a frontend role). My findings suggest that this is not actually a frontend issue and is a problem with the backend. I am uncertain about how to proceed with my assignment submission under these circumstances. Any guidance or assistance on this matter would be greatly appreciated.

Thank you!

naveen521kk avatar Nov 03 '23 14:11 naveen521kk

@naveen521kk i think you have it spot on. make a PR, I will assign this issue to you to avoid too many people trying to solve the same problem.

0x0elliot avatar Nov 03 '23 17:11 0x0elliot

@naveen521kk join our discord to get a faster response from me: https://discord.gg/wwptPnjqEt

keep me updated on this so that if you're not looking forward to solving this, i can assign it to someone else? :)

this is a small bug, shouldn't take you so long.

0x0elliot avatar Nov 03 '23 17:11 0x0elliot

hi! i just came to check on this issue through octernship. Seems like @naveen521kk already solved it though?.....are there other issues that we could work on?

yagyesh-bobde avatar Nov 03 '23 20:11 yagyesh-bobde

@yagyesh-bobde sort with good-first-issue's and beginner-friendly issues :)

0x0elliot avatar Nov 03 '23 20:11 0x0elliot

cool. I work on them _

yagyesh-bobde avatar Nov 03 '23 20:11 yagyesh-bobde

Then, How the Submissions will work for Octernships ?? Most of the students can replicate this answer in their assignments + This is not an frontend issue.

myselfprincee avatar Nov 04 '23 14:11 myselfprincee

For folks who are here for Github Octernship:

To clear things up, the Frontend assignment will be updated soon to a new one. There was miscommunication from our end on how you all are supposed to approach the assignment. We are working with Github to make sure everyone's got equal opportunity to work on it.

What happens now? What you should know? The frontend assignment will be updated. Disregard any communications made here or on Github issue previously. Read how to submit the assignment under Task Submission in the assignment very carefully before doing anything. Make sure you keep your work private and follow the instructions.

If you have any questions, LMK.

jaygohil-cyber avatar Nov 04 '23 18:11 jaygohil-cyber

For folks who are here for Github Octernship:

To clear things up, the Frontend assignment will be updated soon to a new one. There was miscommunication from our end on how you all are supposed to approach the assignment. We are working with Github to make sure everyone's got equal opportunity to work on it.

What happens now? What you should know? The frontend assignment will be updated. Disregard any communications made here or on Github issue previously. Read how to submit the assignment under Task Submission in the assignment very carefully before doing anything. Make sure you keep your work private and follow the instructions.

If you have any questions, LMK.

Thanks for Making everything clear. Appreciate it ❤️

myselfprincee avatar Nov 04 '23 18:11 myselfprincee

image hello I am facing this issue with setting up local development @FranciscoJavierPizarro

dassudip2001 avatar Nov 05 '23 13:11 dassudip2001

Please assign, so I'll make a PR

hollermay avatar Nov 06 '23 17:11 hollermay

Please assign, so I'll make a PR

@hollermay check this https://github.com/Shuffle/Shuffle/issues/1176#issuecomment-1793512027.

jaygohil-cyber avatar Nov 07 '23 04:11 jaygohil-cyber

edit

Can you describe steps to reproduce it or upload video for the same? @VinayakVispute

JayeshYadav99 avatar Nov 07 '23 07:11 JayeshYadav99

Pls can I get assigned

GZMaster avatar Nov 07 '23 13:11 GZMaster

I want to work on this issue please assign me

techmannih avatar Nov 07 '23 14:11 techmannih

@GZMaster @techmannih https://github.com/Shuffle/Shuffle/issues/1176#issuecomment-1793512027

There is no assignment - just get it done in your local environment :)

frikky avatar Nov 07 '23 17:11 frikky

@frikky Can i create new issue in your website as a frontend and raise a PR for this after assigned

techmannih avatar Nov 07 '23 18:11 techmannih

@frikky Can i create new issue in your website as a frontend and raise a PR for this after assigned

Of course you can create a new issue. We do however not want website suggestions as much as product improvements.

This issue is for Shuffle as an open source product, not a website.

frikky avatar Nov 07 '23 19:11 frikky

@frikky Can I create a new issue in the frontend of this https://Shuffler.io as same as #1238

techmannih avatar Nov 08 '23 04:11 techmannih

Alright folks, if you didn't notice, the assignment has been updated! Go back to the assignment, check the updates, and let me know if you have any questions!

Please read the assignment and Task Submission carefully!

Plus, as I mentioned, disregard all the communications that have happened. And just follow the instructions on the assignment's Task Submission section. The assignment is on Github's octernship website (the one where you saw it for the first time).

I will be your sole point of contact. Direct all your questions to me! You can do that on Github Discussion or on Discord.

jaygohil-cyber avatar Nov 08 '23 04:11 jaygohil-cyber

The assignment isn't updating on my end

hollermay avatar Nov 08 '23 05:11 hollermay

The assignment isn't updating on my end

same issue

dassudip2001 avatar Nov 08 '23 05:11 dassudip2001