dont reupload files if already on server

This commit is contained in:
j 2013-09-26 21:58:06 +00:00
parent 054d07fcf3
commit e24f83d4c6
2 changed files with 56 additions and 36 deletions

View file

@ -371,6 +371,8 @@ class File(models.Model):
for key in self.PATH_INFO: for key in self.PATH_INFO:
data[key] = self.info.get(key) data[key] = self.info.get(key)
data['users'] = list(set([i['user'] for i in data['instances']])) data['users'] = list(set([i['user'] for i in data['instances']]))
if 'item' in keys:
data['item'] = self.item.itemId
if keys: if keys:
for k in data.keys(): for k in data.keys():
if k not in keys: if k not in keys:

View file

@ -206,44 +206,62 @@ pandora.ui.uploadVideoDialog = function(data) {
resetProgress(); resetProgress();
$info.html(Ox._('Uploading {0}', [file.name])); $info.html(Ox._('Uploading {0}', [file.name]));
Ox.oshash(file, function(oshash) { Ox.oshash(file, function(oshash) {
pandora.api.addMedia({ pandora.api.findMedia({
filename: file.name, query: {
id: oshash, conditions: [{key: 'oshash', value: oshash}]
item: pandora.site.itemRequiresVideo ? undefined : pandora.user.ui.item },
keys: ['id', 'item', 'available']
}, function(result) { }, function(result) {
var item = result.data.item; if (
pandora.$ui.upload = pandora.chunkupload({ result.data.items.length === 0
file: file, || !result.data.items[0].available
url: '/api/upload/direct/', ) {
data: { pandora.api.addMedia({
id: oshash filename: file.name,
} id: oshash,
}).bindEvent({ item: pandora.site.itemRequiresVideo ? undefined : pandora.user.ui.item
done: function(data) { }, function(result) {
if (data.progress == 1) { var item = result.data.item;
Ox.Request.clearCache(); pandora.$ui.upload = pandora.chunkupload({
if (pandora.user.ui.item == item && pandora.user.ui.itemView == 'media') { file: file,
pandora.$ui.item.reload(); url: '/api/upload/direct/',
} else { data: {
pandora.UI.set({ id: oshash
item: item,
itemView: 'media'
});
} }
that.close(); }).bindEvent({
} else { done: function(data) {
$status.html(cancelled ? Ox._('Upload cancelled.') : Ox._('Upload failed.')); if (data.progress == 1) {
!cancelled && pandora.api.log({ Ox.Request.clearCache();
text: data.responseText, if (pandora.user.ui.item == item && pandora.user.ui.itemView == 'media') {
url: '/' + item, pandora.$ui.item.reload();
line: 1 } else {
}); pandora.UI.set({
} item: item,
}, itemView: 'media'
progress: function(data) { });
$progress.options({progress: data.progress || 0}); }
} that.close();
}); } else {
$status.html(cancelled ? Ox._('Upload cancelled.') : Ox._('Upload failed.'));
!cancelled && pandora.api.log({
text: data.responseText,
url: '/' + item,
line: 1
});
}
},
progress: function(data) {
$progress.options({progress: data.progress || 0});
}
});
});
} else {
pandora.UI.set({
item: result.data.items[0].item,
itemView: 'media'
});
that.close();
}
}); });
}); });
} }