pull/1496/head
Piero Toffanin 2024-05-08 12:13:21 -04:00
commit d46b582dcd
3 zmienionych plików z 8 dodań i 5 usunięć

Wyświetl plik

@ -207,14 +207,14 @@ class TaskViewSet(viewsets.ViewSet):
if len(files) == 0:
raise exceptions.ValidationError(detail=_("No files uploaded"))
task.handle_images_upload(files)
uploaded = task.handle_images_upload(files)
task.images_count = len(task.scan_images())
# Update other parameters such as processing node, task name, etc.
serializer = TaskSerializer(task, data=request.data, partial=True)
serializer.is_valid(raise_exception=True)
serializer.save()
return Response({'success': True}, status=status.HTTP_200_OK)
return Response({'success': True, 'uploaded': uploaded}, status=status.HTTP_200_OK)
@action(detail=True, methods=['post'])
def duplicate(self, request, pk=None, project_pk=None):

Wyświetl plik

@ -1163,6 +1163,7 @@ class Task(models.Model):
return path_traversal_check(p, self.task_path())
def handle_images_upload(self, files):
uploaded = {}
for file in files:
name = file.name
if name is None:
@ -1181,6 +1182,9 @@ class Task(models.Model):
else:
with open(file.temporary_file_path(), 'rb') as f:
shutil.copyfileobj(f, fd)
uploaded[name] = os.path.getsize(dst_path)
return uploaded
def update_size(self, commit=False):
try:

Wyświetl plik

@ -193,7 +193,7 @@ class ProjectListItem extends React.Component {
.on("complete", (file) => {
// Retry
const retry = () => {
const MAX_RETRIES = 10;
const MAX_RETRIES = 20;
if (file.retries < MAX_RETRIES){
// Update progress
@ -231,7 +231,7 @@ class ProjectListItem extends React.Component {
}else{
// Check response
let response = JSON.parse(file.xhr.response);
if (response.success){
if (response.success && response.uploaded && response.uploaded[file.name] === file.size){
// Update progress by removing the tracked progress and
// use the file size as the true number of bytes
let totalBytesSent = this.state.upload.totalBytesSent + file.size;
@ -284,7 +284,6 @@ class ProjectListItem extends React.Component {
}else if (this.dz.getQueuedFiles() === 0){
// Done but didn't upload all?
this.setUploadState({
totalCount: this.state.upload.totalCount - remainingFilesCount,
uploading: false,
error: interpolate(_('%(count)s files cannot be uploaded. As a reminder, only images (.jpg, .tif, .png) and GCP files (.txt) can be uploaded. Try again.'), { count: remainingFilesCount })
});