"File not found" when downloading one single file from folder by selection #24783

Closed
popov-d opened this Issue May 23, 2016 · 3 comments

Projects

None yet

2 participants

@popov-d
Contributor
popov-d commented May 23, 2016

Steps to reproduce

  1. Create an empty folder
  2. Upload a single file into it
  3. When standing in that folder, mark that file, either with a checkbox on it, or with a "mark all" checkbox above filename column. A note "1 file" appears above file list, and a "Download" link right from it.
  4. Click that Download link

Expected behaviour

The selected file should be downloaded.

Actual behaviour

Error page appears with message:

File not found
The specified document has not been found on the server.

Apache log file shows a 404 error like this:

192.168.5.2 - - [23/May/2016:17:15:45 +0300] "GET /cloud/index.php/apps/files/ajax/download.php?dir=%2F&files=fmdata-1b1eA6-0000wD-4x.eml&downloadStartSecret=3mmnyvubg7v HTTP/1.1" 404 11012 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:46.0) Gecko/20100101 Firefox/46.0"

Note that although requested file was in a subfolder, download link has dir=/ in it. The last component of path to folder is missing. That happens when there is exactly one file in a directory and it is downloaded via "Download" link for selected files. The ... / Download method works ok. When there are more than one file in a directory, any download works ok, regardless of how you select them.

The problem seems to be in apps/files/js/filelist.js, the _onClickDownloadSelected handler. As I understand, it tries to convert the "all selected" situation to "parent folder selected". But makes it in a slightly incorrect way, since first and second parts of the job are done with different conditions. In the case of single file in a folder this.getDownloadUrl() is called with dir as parent directory, but filename in current directory. That's why the last directory component is missing from URL in log, and that's why file is not found, since it's one directory below.

I made and quick and dirty fix for me by adding an OR to the last branching condition like that: if(this.getSelectedFiles().length > 1 || this.isAllSelected()) {
It has a drawback — a single file is now downloaded not as itself, but as a ZIP with a folder with that file inside. Still hope it illustrates the idea of what is happening. I can make a pull request, if it makes sense.

Server configuration

(I think all below is irrelevant to this issue, should be the same on any current installation. Things above don't depend on any configuration-related conditions. Reproduced this bug also on another differently configured server, but I don't have access to their configuration.)

Operating system: Debian 8.4 with current updates

Web server: Apache 2.4.10 from Debian repository

Database: MySQL 5.5.49 from Debian

PHP version: PHP 5.6.20 from Debian

ownCloud version: 9.0.2

Updated from an older ownCloud or fresh install: started as 7.0, updated many times to 8.x and 9.x.

Where did you install ownCloud from: deb http://download.owncloud.org/download/repositories/stable/Debian_8.0/ /

Signing status (ownCloud 9.0 and above): .htaccess changed, file limit sizes increased to 32 GB

List of activated apps:
Enabled:

  • activity: 2.2.1
  • comments: 0.2
  • dav: 0.1.6
  • federatedfilesharing: 0.1.0
  • files: 1.4.4
  • files_pdfviewer: 0.8.1
  • files_sharing: 0.9.1
  • files_texteditor: 2.1
  • files_trashbin: 0.8.0
  • files_versions: 1.2.0
  • files_videoplayer: 0.9.8
  • notifications: 0.2.3
  • provisioning_api: 0.4.1
  • systemtags: 0.2
    Disabled:
  • encryption
  • external
  • federation
  • files_external
  • firstrunwizard
  • gallery
  • templateeditor
  • updatenotification
  • user_external
  • user_ldap

The content of config/config.php: (sensitive parts skipped)

array ( 0 => 'cloud.krista.ru', ), 'datadirectory' => '/var/www/owncloud/data', 'dbtype' => 'mysql', 'version' => '9.0.2.2', 'dbname' => 'owncloud', 'dbhost' => 'localhost', 'dbtableprefix' => 'oc_', 'installed' => true, 'default_language' => 'ru', 'knowledgebaseenabled' => false, 'enable_avatars' => true, 'mail_domain' => 'krista.ru', 'mail_from_address' => 'cloud', 'mail_smtpmode' => 'smtp', 'mail_smtphost' => 'localhost', 'mail_smtpport' => '25', 'overwritehost' => 'cloud.krista.ru', 'overwriteprotocol' => 'https', 'overwritewebroot' => '/', 'overwrite.cli.url' => 'https://cloud.krista.ru', 'trashbin_retention_obligation' => 'auto', 'updatechecker' => false, 'has_internet_connection' => false, 'loglevel' => 2, 'logdateformat' => 'Y-m-d H:i:s', 'logtimezone' => 'Europe/Moscow', 'cron_log' => true, 'appstoreenabled' => false, 'enable_previews' => false, 'maintenance' => false, 'memcache.local' => '\OC\Memcache\APCu', 'asset-pipeline.enabled' => true, 'log_authfailip' => true, 'skeletondirectory' => '/var/local/owncloud-skeleton', ); **Are you using external storage, if yes which one:** No **Are you using encryption:** No **Are you using an external user-backend, if yes which one:** No ### Client configuration **Browser:** Mozilla Firefox 46.0.1 **Operating system:** Ubuntu 16.04 with updates ### Logs #### Web server error log Example of problematic request: 192.168.5.2 - - [23/May/2016:17:15:45 +0300] "GET /cloud/index.php/apps/files/ajax/download.php?dir=%2F&files=fmdata-1b1eA6-0000wD-4x.eml&downloadStartSecret=3mmnyvubg7v HTTP/1.1" 404 11012 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:46.0) Gecko/20100101 Firefox/46.0" #### ownCloud log (data/owncloud.log) Nothing goes to this log on this error. #### Browser log Nothing special happens here.
@ghost
ghost commented May 23, 2016

Duplicate of #24272 and/or #23613

@popov-d
Contributor
popov-d commented May 23, 2016
  Duplicate of #24272
    and/or #23613

Sorry, unfortunately they didn't appear in search, may be I tried
not enough words. Both obviously describe the same situation, but my
version at least has a partial fix. Maybe I make it better tomorrow.
I also have some problems with Github — works slowly, occasionally
gives 500 errors and I don't see my last commit in web interface.
Hope all this goes away after some time.

-- 
  Попов Дмитрий Евгеньевич, ведущий системный
    администратор,
    popov@krista.ru, +7 4855
    291511, кабинет 218
    НПО Криста, http://www.krista.ru
@popov-d popov-d added a commit to popov-d/core that referenced this issue May 23, 2016
@popov-d popov-d Fix for owncloud#24783 , described there 97d891d
@ghost
ghost commented May 23, 2016

Yeah, seems github has currently some issues: https://status.github.com/

I think PR and fixes for this issues are welcome at the linked bugreports.

@PVince81 PVince81 added a commit that referenced this issue May 24, 2016
@popov-d @PVince81 popov-d + PVince81 My fix for #24272, #23613, File not found when single file in a folder (
#24800)

* Fixed group share searching for members of
multiple group. Issue #11808.

* Fixed group share searching, continued.

Avoid searching for empty group list in getItemSharedWithUser().
Broke tests in previous commit, #12030.

* Simler check for group count.

* Fix for #24783 , described there

* Now it's #24272, 24783 was a duplicate. Previous change was also not very good. Now we don't create ZIP with a single file inside.
83aa28e
@PVince81 PVince81 added a commit that referenced this issue Jun 2, 2016
@popov-d @PVince81 popov-d + PVince81 My fix for #24272, #23613, File not found when single file in a folder (
#24800)

* Fixed group share searching for members of
multiple group. Issue #11808.

* Fixed group share searching, continued.

Avoid searching for empty group list in getItemSharedWithUser().
Broke tests in previous commit, #12030.

* Simler check for group count.

* Fix for #24783 , described there

* Now it's #24272, 24783 was a duplicate. Previous change was also not very good. Now we don't create ZIP with a single file inside.
825d1c1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment