e30e3209 by Ean Schuessler

WIP, sync with Adam

Refs: #7621
1 parent 1a60a492
......@@ -5,7 +5,6 @@ define(function(require) {
var Backbone = require('backbone');
var Flow = require('flow');
var api = require('api');
var OwnerContent = require('models/OwnerContent');
var Status = Backbone.Model.extend({
defaults: function() {
......@@ -75,47 +74,9 @@ define(function(require) {
Status: Status,
flowEventHandlers: {
uploadStart: function() {
var self = this;
// Pre-allocate the contentIds for each file's upload
if (!this.model.get('prechecked')) {
this.flow.pause();
var ownerContentDeferreds = [];
self.model.get('collection').each(function(file) {
if (file.flowFile != undefined) {
var flowFile = file.flowFile;
var flowTotalChunks = Math.floor(file.get('size') / flowFile.flowObj.opts.chunkSize);
if (flowTotalChunks == 0) {
flowTotalChunks = 1;
}
var ownerContent = new OwnerContent({
flowChunkNumber: 0,
flowChunkSize: flowFile.flowObj.opts.chunkSize,
flowCurrentChunkSize: (file.get('size') < flowFile.flowObj.opts.chunkSize) ? file.get('size') : flowFile.flowObj.opts.chunkSize,
flowTotalSize: file.get('size'),
flowIdentifier: flowFile.uniqueIdentifier,
flowFilename: flowFile.name,
flowRelativePath: flowFile.relativePath,
flowTotalChunks: flowTotalChunks
});
flowFile.flowObj.ownerContent = ownerContent;
var deferred = ownerContent.save();
ownerContentDeferreds.push(deferred);
}
});
$.when(ownerContentDeferreds).done(function(ownerContent) {
self.model.set('prechecked', true);
self.flow.resume();
setTimeout(function() {
self.model.set('prechecked', false);
}, 500);
});
if (this.model.get('handlers') && this.model.get('handlers').uploadStart !== undefined) {
this.model.get('handlers').uploadStart();
}
}
},
fileAdded: function(flowFile) {
var model = flowFile._model;
......