Skip to content
Snippets Groups Projects
Commit 2fee2df5 authored by vkovtun's avatar vkovtun
Browse files

BIS-753: Implemented improvements to file conflict resolution logic.

parent b64eec87
No related branches found
No related tags found
1 merge request!40SSDM-13578 : 2PT : Database and V3 Implementation - include the new AFS "free"...
......@@ -35,7 +35,7 @@ class FileExistsDialog extends React.Component {
open={open}
onClose={this.handleClose}
title={title || messages.get(messages.CONFIRMATION)}
content={<Message type={this.getMessageType()}>{content}</Message>}
content={<Message type={'warning'}>{content}</Message>}
actions={this.renderButtons()}
/>
)
......@@ -45,38 +45,35 @@ class FileExistsDialog extends React.Component {
const { onReplace, onResume, onCancel, classes } = this.props
return (
<div>
{!!onReplace && <Button
name='replace'
label={messages.get(messages.REPLACE)}
type={this.getButtonType()}
styles={{ root: classes.button }}
onClick={onReplace}
/>}
{!!onResume && <Button
name='resume'
label={messages.get(messages.RESUME)}
type={this.getButtonType()}
styles={{ root: classes.button }}
onClick={onResume}
/>}
{!!onCancel && <Button
name='cancel'
label={messages.get(messages.CANCEL)}
styles={{ root: classes.button }}
onClick={onCancel}
/>}
{!!onReplace && (
<Button
name='replace'
label={messages.get(messages.REPLACE)}
type={'risky'}
styles={{ root: classes.button }}
onClick={onReplace}
/>
)}
{!!onResume && (
<Button
name='resume'
label={messages.get(messages.RESUME)}
type={'risky'}
styles={{ root: classes.button }}
onClick={onResume}
/>
)}
{!!onCancel && (
<Button
name='cancel'
label={messages.get(messages.CANCEL)}
styles={{ root: classes.button }}
onClick={onCancel}
/>
)}
</div>
)
}
getMessageType() {
return 'warning'
}
getButtonType() {
return 'risky'
}
}
export default withStyles(styles)(FileExistsDialog)
......@@ -175,12 +175,19 @@ export default class DataBrowserController extends ComponentController {
: file.name
const targetFilePath = this.path + '/' + filePath
const existingFiles = await this.listFiles(targetFilePath)
const existingFileSize = existingFiles.length === 0 ? 0
: existingFiles[0].size
// If the file is smaller than 2 chunks we better replace it
const allowResume = file.size >= 2 * CHUNK_SIZE
&& file.size >= existingFileSize
const resolutionResult = existingFiles.length === 0 ? 'replace'
: await onNameConflictFound(file)
: await onNameConflictFound(file, allowResume)
if (resolutionResult !== 'cancel') {
// Replace or resume upload from the last point in the file
let offset = resolutionResult === 'replace' ? 0 : existingFiles[0].size
let offset = resolutionResult === 'replace' ? 0 : existingFileSize
totalUploaded += Math.min(offset, file.size)
while (offset < file.size) {
const blob = file.slice(offset, offset + CHUNK_SIZE)
const binaryString = await this._fileSliceToBinaryString(blob)
......
......@@ -102,13 +102,13 @@ class RightToolbar extends React.Component {
}
}
updateProgress(newProgress) {
this.setState({ progress: newProgress })
updateProgress(progress) {
this.setState({ progress })
}
async resolveNameConflict(newFile) {
async resolveNameConflict(newFile, allowResume) {
return new Promise((resolve) => {
debugger
this.setState({ allowResume })
this.openFileExistsDialog(newFile)
this.resolveConflict = resolve
})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment