WIP, sync with Adam
Refs: #7621
Showing
1 changed file
with
2 additions
and
41 deletions
... | @@ -5,7 +5,6 @@ define(function(require) { | ... | @@ -5,7 +5,6 @@ define(function(require) { |
5 | var Backbone = require('backbone'); | 5 | var Backbone = require('backbone'); |
6 | var Flow = require('flow'); | 6 | var Flow = require('flow'); |
7 | var api = require('api'); | 7 | var api = require('api'); |
8 | var OwnerContent = require('models/OwnerContent'); | ||
9 | 8 | ||
10 | var Status = Backbone.Model.extend({ | 9 | var Status = Backbone.Model.extend({ |
11 | defaults: function() { | 10 | defaults: function() { |
... | @@ -75,46 +74,8 @@ define(function(require) { | ... | @@ -75,46 +74,8 @@ define(function(require) { |
75 | Status: Status, | 74 | Status: Status, |
76 | flowEventHandlers: { | 75 | flowEventHandlers: { |
77 | uploadStart: function() { | 76 | uploadStart: function() { |
78 | var self = this; | 77 | if (this.model.get('handlers') && this.model.get('handlers').uploadStart !== undefined) { |
79 | // Pre-allocate the contentIds for each file's upload | 78 | this.model.get('handlers').uploadStart(); |
80 | if (!this.model.get('prechecked')) { | ||
81 | this.flow.pause(); | ||
82 | |||
83 | var ownerContentDeferreds = []; | ||
84 | self.model.get('collection').each(function(file) { | ||
85 | if (file.flowFile != undefined) { | ||
86 | var flowFile = file.flowFile; | ||
87 | var flowTotalChunks = Math.floor(file.get('size') / flowFile.flowObj.opts.chunkSize); | ||
88 | if (flowTotalChunks == 0) { | ||
89 | flowTotalChunks = 1; | ||
90 | } | ||
91 | var ownerContent = new OwnerContent({ | ||
92 | flowChunkNumber: 0, | ||
93 | flowChunkSize: flowFile.flowObj.opts.chunkSize, | ||
94 | flowCurrentChunkSize: (file.get('size') < flowFile.flowObj.opts.chunkSize) ? file.get('size') : flowFile.flowObj.opts.chunkSize, | ||
95 | flowTotalSize: file.get('size'), | ||
96 | flowIdentifier: flowFile.uniqueIdentifier, | ||
97 | flowFilename: flowFile.name, | ||
98 | flowRelativePath: flowFile.relativePath, | ||
99 | flowTotalChunks: flowTotalChunks | ||
100 | }); | ||
101 | flowFile.flowObj.ownerContent = ownerContent; | ||
102 | var deferred = ownerContent.save(); | ||
103 | ownerContentDeferreds.push(deferred); | ||
104 | } | ||
105 | }); | ||
106 | |||
107 | $.when(ownerContentDeferreds).done(function(ownerContent) { | ||
108 | self.model.set('prechecked', true); | ||
109 | self.flow.resume(); | ||
110 | setTimeout(function() { | ||
111 | self.model.set('prechecked', false); | ||
112 | }, 500); | ||
113 | }); | ||
114 | |||
115 | if (this.model.get('handlers') && this.model.get('handlers').uploadStart !== undefined) { | ||
116 | this.model.get('handlers').uploadStart(); | ||
117 | } | ||
118 | } | 79 | } |
119 | }, | 80 | }, |
120 | fileAdded: function(flowFile) { | 81 | fileAdded: function(flowFile) { | ... | ... |
-
Please register or sign in to post a comment