Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>tags/v29.0.0beta1
$parentPath = ''; | $parentPath = ''; | ||||
} | } | ||||
$req = $this->server->httpRequest; | $req = $this->server->httpRequest; | ||||
// If chunked upload | |||||
if ($req->getHeader('OC-Chunked')) { | if ($req->getHeader('OC-Chunked')) { | ||||
$info = \OC_FileChunking::decodeName($newName); | $info = \OC_FileChunking::decodeName($newName); | ||||
$chunkHandler = $this->getFileChunking($info); | $chunkHandler = $this->getFileChunking($info); | ||||
// use target file name for free space check in case of shared files | // use target file name for free space check in case of shared files | ||||
$path = rtrim($parentPath, '/') . '/' . $info['name']; | $path = rtrim($parentPath, '/') . '/' . $info['name']; | ||||
} | } | ||||
// Strip any duplicate slashes | |||||
$path = str_replace('//', '/', $path); | |||||
$freeSpace = $this->getFreeSpace($path); | $freeSpace = $this->getFreeSpace($path); | ||||
if ($freeSpace >= 0 && $length > $freeSpace) { | if ($freeSpace >= 0 && $length > $freeSpace) { | ||||
if (isset($chunkHandler)) { | if (isset($chunkHandler)) { |
mounted() { | mounted() { | ||||
// Warn the user if the available storage is 0 on page load | // Warn the user if the available storage is 0 on page load | ||||
if (this.storageStats?.free === 0) { | |||||
if (this.storageStats?.free <= 0) { | |||||
this.showStorageFullWarning() | this.showStorageFullWarning() | ||||
} | } | ||||
}, | }, | ||||
} | } | ||||
// Warn the user if the available storage changed from > 0 to 0 | // Warn the user if the available storage changed from > 0 to 0 | ||||
if (this.storageStats?.free !== 0 && response.data.data?.free === 0) { | |||||
if (this.storageStats?.free > 0 && response.data.data?.free <= 0) { | |||||
this.showStorageFullWarning() | this.showStorageFullWarning() | ||||
} | } | ||||
:destination="currentFolder" | :destination="currentFolder" | ||||
:multiple="true" | :multiple="true" | ||||
class="files-list__header-upload-button" | class="files-list__header-upload-button" | ||||
@failed="onUploadFail" | |||||
@uploaded="onUpload" /> | @uploaded="onUpload" /> | ||||
</template> | </template> | ||||
</BreadCrumbs> | </BreadCrumbs> | ||||
import { getCapabilities } from '@nextcloud/capabilities' | import { getCapabilities } from '@nextcloud/capabilities' | ||||
import { join, dirname } from 'path' | import { join, dirname } from 'path' | ||||
import { orderBy } from 'natural-orderby' | import { orderBy } from 'natural-orderby' | ||||
import { Parser } from 'xml2js' | |||||
import { showError } from '@nextcloud/dialogs' | |||||
import { translate, translatePlural } from '@nextcloud/l10n' | import { translate, translatePlural } from '@nextcloud/l10n' | ||||
import { Type } from '@nextcloud/sharing' | import { Type } from '@nextcloud/sharing' | ||||
import { UploadPicker } from '@nextcloud/upload' | import { UploadPicker } from '@nextcloud/upload' | ||||
} | } | ||||
}, | }, | ||||
async onUploadFail(upload: Upload) { | |||||
const status = upload.response?.status || 0 | |||||
// Check known status codes | |||||
if (status === 507) { | |||||
showError(this.t('files', 'Not enough free space')) | |||||
return | |||||
} else if (status === 404 || status === 409) { | |||||
showError(this.t('files', 'Target folder does not exist any more')) | |||||
return | |||||
} else if (status === 403) { | |||||
showError(this.t('files', 'Operation is blocked by access control')) | |||||
return | |||||
} else if (status !== 0) { | |||||
showError(this.t('files', 'Error when assembling chunks, status code {status}', { status })) | |||||
return | |||||
} | |||||
// Else we try to parse the response error message | |||||
try { | |||||
const parser = new Parser({ trim: true, explicitRoot: false }) | |||||
const response = await parser.parseStringPromise(upload.response?.data) | |||||
const message = response['s:message'][0] as string | |||||
if (typeof message === 'string' && message.trim() !== '') { | |||||
// Unfortunatly, the server message is not translated | |||||
showError(this.t('files', 'Error during upload: {message}', { message })) | |||||
return | |||||
} | |||||
} catch (error) {} | |||||
showError(this.t('files', 'Unknown error during upload')) | |||||
}, | |||||
openSharingSidebar() { | openSharingSidebar() { | ||||
if (window?.OCA?.Files?.Sidebar?.setActiveTab) { | if (window?.OCA?.Files?.Sidebar?.setActiveTab) { | ||||
window.OCA.Files.Sidebar.setActiveTab('sharing') | window.OCA.Files.Sidebar.setActiveTab('sharing') |
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */ | /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */ | ||||
/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */ | |||||
/** | /** | ||||
* @copyright 2021 Christoph Wurst <christoph@winzerhof-wurst.at> | * @copyright 2021 Christoph Wurst <christoph@winzerhof-wurst.at> | ||||
* | * |
/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */ | |||||
/** | /** | ||||
* @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at> | * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at> | ||||
* | * |
* @license MIT | * @license MIT | ||||
*/ | */ | ||||
/*! http://mths.be/fromcodepoint v0.1.0 by @mathias */ | |||||
/** | /** | ||||
* @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at> | * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at> | ||||
* | * |
/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */ | |||||
/** | /** | ||||
* @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at> | * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at> | ||||
* | * |
"vuedraggable": "^2.24.3", | "vuedraggable": "^2.24.3", | ||||
"vuex": "^3.6.2", | "vuex": "^3.6.2", | ||||
"vuex-router-sync": "^5.0.0", | "vuex-router-sync": "^5.0.0", | ||||
"webdav": "^5.3.1" | |||||
"webdav": "^5.3.1", | |||||
"xml2js": "^0.6.2" | |||||
}, | }, | ||||
"devDependencies": { | "devDependencies": { | ||||
"@babel/node": "^7.22.10", | "@babel/node": "^7.22.10", | ||||
"xml2js": "^0.4.5" | "xml2js": "^0.4.5" | ||||
} | } | ||||
}, | }, | ||||
"node_modules/parse-bmfont-xml/node_modules/xml2js": { | |||||
"version": "0.4.23", | |||||
"resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.23.tgz", | |||||
"integrity": "sha512-ySPiMjM0+pLDftHgXY4By0uswI3SPKLDw/i3UXbnO8M/p28zqexCUoPmQFrYD+/1BzhGJSs2i1ERWKJAtiLrug==", | |||||
"dependencies": { | |||||
"sax": ">=0.6.0", | |||||
"xmlbuilder": "~11.0.0" | |||||
}, | |||||
"engines": { | |||||
"node": ">=4.0.0" | |||||
} | |||||
}, | |||||
"node_modules/parse-headers": { | "node_modules/parse-headers": { | ||||
"version": "2.0.5", | "version": "2.0.5", | ||||
"resolved": "https://registry.npmjs.org/parse-headers/-/parse-headers-2.0.5.tgz", | "resolved": "https://registry.npmjs.org/parse-headers/-/parse-headers-2.0.5.tgz", | ||||
"integrity": "sha512-ErcKwJTF54uRzzNMXq2X5sMIy88zJvfN2DmdoQvy7PAFJ+tPRU6ydWuOKNMyfmOjdyBQTFREi60s0Y0SyI0G0g==" | "integrity": "sha512-ErcKwJTF54uRzzNMXq2X5sMIy88zJvfN2DmdoQvy7PAFJ+tPRU6ydWuOKNMyfmOjdyBQTFREi60s0Y0SyI0G0g==" | ||||
}, | }, | ||||
"node_modules/xml2js": { | "node_modules/xml2js": { | ||||
"version": "0.4.23", | |||||
"resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.23.tgz", | |||||
"integrity": "sha512-ySPiMjM0+pLDftHgXY4By0uswI3SPKLDw/i3UXbnO8M/p28zqexCUoPmQFrYD+/1BzhGJSs2i1ERWKJAtiLrug==", | |||||
"version": "0.6.2", | |||||
"resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.6.2.tgz", | |||||
"integrity": "sha512-T4rieHaC1EXcES0Kxxj4JWgaUQHDk+qwHcYOCFHfiwKz7tOVPLq7Hjq9dM1WCMhylqMEfP7hMcOIChvotiZegA==", | |||||
"dependencies": { | "dependencies": { | ||||
"sax": ">=0.6.0", | "sax": ">=0.6.0", | ||||
"xmlbuilder": "~11.0.0" | "xmlbuilder": "~11.0.0" |
"vuedraggable": "^2.24.3", | "vuedraggable": "^2.24.3", | ||||
"vuex": "^3.6.2", | "vuex": "^3.6.2", | ||||
"vuex-router-sync": "^5.0.0", | "vuex-router-sync": "^5.0.0", | ||||
"webdav": "^5.3.1" | |||||
"webdav": "^5.3.1", | |||||
"xml2js": "^0.6.2" | |||||
}, | }, | ||||
"devDependencies": { | "devDependencies": { | ||||
"@babel/node": "^7.22.10", | "@babel/node": "^7.22.10", |