1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-01 07:01:12 +00:00

repair upload bug

This commit is contained in:
shanshuirenjia
2019-07-04 18:49:16 +08:00
parent f007e58c0e
commit 7211ac3ab3

View File

@@ -128,44 +128,31 @@ class FileUploader extends React.Component {
this.resumable.on('dragstart', this.onDragStart.bind(this));
}
onChunkingComplete = (file) => {
if (file.relativePath !== file.fileName) {
return; // is upload a folder;
}
if (enableResumableFileUpload) {
let repoID = this.props.repoID;
seafileAPI.getFileUploadedBytes(repoID, this.props.path, file.fileName).then(res => {
let uploadedBytes = res.data.uploadedBytes;
let offset = Math.floor(uploadedBytes / (1024 * 1024));
file.markChunksCompleted(offset);
this.resumable.upload();
});
}
}
onFileAdded = (resumableFile, files) => {
//get parent_dir、relative_path
onChunkingComplete = (resumableFile) => {
//get parent_dir relative_path
let path = this.props.path === '/' ? '/' : this.props.path + '/';
let fileName = resumableFile.fileName;
let relativePath = resumableFile.relativePath;
let isFile = fileName === relativePath;
//update formdata
//update formdata
resumableFile.formData = {};
if (isFile) {
if (isFile) { // upload file
resumableFile.formData = {
parent_dir: path,
};
} else {
} else { // upload folder
let relative_path = relativePath.slice(0, relativePath.lastIndexOf('/') + 1);
resumableFile.formData = {
parent_dir: path,
relative_path: relative_path
};
}
}
//check repetition
//uploading is file and only upload one file
onFileAdded = (resumableFile, files) => {
let isFile = resumableFile.fileName === resumableFile.relativePath;
// uploading is file and only upload one file
if (isFile && files.length === 1) {
let hasRepetition = false;
let direntList = this.props.direntList;
@@ -182,18 +169,28 @@ class FileUploader extends React.Component {
});
} else {
this.setUploadFileList(this.resumable.files);
if (!enableResumableFileUpload) {
this.resumable.upload();
}
this.resumableUpload(resumableFile);
}
} else {
} else {
this.setUploadFileList(this.resumable.files);
if (!enableResumableFileUpload) {
if (isFile) {
this.resumableUpload(resumableFile);
} else {
this.resumable.upload();
}
}
}
resumableUpload = (resumableFile) => {
let { repoID, path } = this.props;
seafileAPI.getFileUploadedBytes(repoID, path, resumableFile.fileName).then(res => {
let uploadedBytes = res.data.uploadedBytes;
let offset = Math.floor(uploadedBytes / (1024 * 1024));
resumableFile.markChunksCompleted(offset);
this.resumable.upload();
});
}
filesAddedComplete = (resumable, files) => {
// single file uploading can check repetition, because custom dialog conn't prevent program execution;
}