Skip to content

Upload autorename on client side - #26078

Merged
PVince81 merged 1 commit into
masterfrom
upload-conflictnopost
Sep 22, 2016
Merged

PVince81 merged 1 commit into
masterfrom
upload-conflictnopost

Conversation

@PVince81

@PVince81 PVince81 commented Sep 9, 2016 •

Copy link
Copy Markdown
Contributor

Description

Removes the need for POST to collection which would hit against upload
limits.

The client tries to auto rename the file by adding a suffix "(2)".
It tries to use the file list on the client side to guess a
suitable name. In case a file still cannot be uploaded and creates a
conflict, which can happen when the file was concurrently uploaded, the
logic will continue increasing the suffix.

Related Issue

Fixes #4380 (comment)

Motivation and Context

We don't want to use POST for uploads any more due to PHP size limitations and usage of tmp dir.
The web UI was changed to use PUT for all uploads but the conflict resolution was still using POST.

How Has This Been Tested?

  • TEST: upload same file multiple times, tick "new files" and "existing files" => file uploaded with suffix "(2)"
  • TEST: upload same file multiple times concurrently, tick "new files" and "existing files" => file uploaded with suffix "(2)" (concurrently in two browser windows without refreshing, multiple times)

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

TODOs

  • add unit tests for autorename string logic

@DeepDiver1975 FYI

@PVince81 PVince81 added this to the 9.2 milestone Sep 9, 2016
@mention-bot

Copy link
Copy Markdown

@PVince81, thanks for your PR! By analyzing the annotation information on this pull request, we identified @mrow4a, @DeepDiver1975 and @butonic to be potential reviewers

@PVince81

Copy link
Copy Markdown
Contributor Author

Added unit tests, please review @DeepDiver1975 @butonic @VicDeo

@PVince81

Copy link
Copy Markdown
Contributor Author

Rebased, fixed failing test

@PVince81
PVince81 force-pushed the upload-conflictnopost branch from 9d6359d to 92fa877 Compare September 16, 2016 10:07
@PVince81

Copy link
Copy Markdown
Contributor Author

@PVince81

Copy link
Copy Markdown
Contributor Author

All tests passed now, Jenkins is back! Please review


/**
* Trigger autorename and append "(2)".
* Multiple calls will increment the appended number.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think this is intended to be called form outside of this class. The usual underscore prefix plus a comment should be enough to make it visible.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It is called from "outside". The method is on OC.FileUpload.autoRename but is called inside the OC.Uploader object. (yeah, ideally these should all eventually be in separate files to avoid confusion...)

do {
retry = false;
upload.autoRename();
// if file known to exist on the client side, retry

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this condition should be in the "while" clause. This loop seems weird to me.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@PVince81
PVince81 force-pushed the upload-conflictnopost branch from 92fa877 to 635bfe8 Compare September 20, 2016 18:59
Comment thread apps/files/js/file-upload.js Outdated
this.log('autorename', null, upload);
upload.setConflictMode(OC.FileUpload.CONFLICT_MODE_AUTORENAME);

var retry = true;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

maybe

do {
  upload.autoRename();
} while (this.fileList && this.fileList.inList(upload.getFilename()));

looks better?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

okay, fixed

@PVince81
PVince81 force-pushed the upload-conflictnopost branch from 635bfe8 to 9823d98 Compare September 21, 2016 13:05
@jvillafanez

Copy link
Copy Markdown
Member

👍

Removes the need for POST to collection which would hit against upload
limits.

The client tries to auto rename the file by adding a suffix "(2)".
It tries to use the file list on the client side to guess a
suitable name. In case a file still cannot be uploaded and creates a
conflict, which can happen when the file was concurrently uploaded, the
logic will continue increasing the suffix.
@PVince81
PVince81 force-pushed the upload-conflictnopost branch from 9823d98 to f99ac40 Compare September 22, 2016 08:20
@PVince81

Copy link
Copy Markdown
Contributor Author

Removed obsolete PHP tests

@PVince81
PVince81 merged commit 4593018 into master Sep 22, 2016
@PVince81
PVince81 deleted the upload-conflictnopost branch September 22, 2016 10:35
@lock

lock Bot commented Aug 4, 2019

Copy link
Copy Markdown

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock Bot locked as resolved and limited conversation to collaborators Aug 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

File upload in browser - use PUT if possible

3 participants