Fix #130 — Allow to individually download files from zip

This commit is contained in:
Luc Didry 2019-04-19 23:16:20 +02:00
parent 33f8707240
commit 0700ea7375
No known key found for this signature in database
GPG Key ID: EA868E12D0257E3C
14 changed files with 157 additions and 354 deletions

View File

@ -3,6 +3,7 @@ Revision history for Lufi
0.04.0 2019-??-??
- Allow to zip the files before upload
- Allow to see what's in zip file on download page
- Allow to individually download files from zip file (only if zip created by Lufi)
0.03.7 2019-08-01
- Fix missing default values for some settings (mildis)

View File

@ -133,6 +133,7 @@ sub upload {
->nbslices($json->{total})
->mod_token($c->shortener($c->config('token_length')))
->passwd($salted_pwd)
->zipped($json->{zipped})
->write;
}

View File

@ -26,6 +26,7 @@ has 'slices' => sub {
};
has 'passwd';
has 'abuse';
has 'zipped' => 0;
has 'record' => 0;
has 'app';
@ -78,6 +79,8 @@ Have a look at Lufi::DB::File::SQLite's code: it's simple and may be more unders
=item B<abuse> : integer
=item B<zipped> : boolean
=item B<app> : a Mojolicious object
=back
@ -175,9 +178,9 @@ sub write {
my $c = shift;
if ($c->record) {
$c->app->dbi->db->query('UPDATE files SET short = ?, deleted = ?, mediatype = ?, filename = ?, filesize = ?, counter = ?, delete_at_first_view = ?, delete_at_day = ?, created_at = ?, created_by = ?, last_access_at = ?, mod_token = ?, nbslices = ?, complete = ?, passwd = ?, abuse = ? WHERE short = ?', $c->short, $c->deleted, $c->mediatype, $c->filename, $c->filesize, $c->counter, $c->delete_at_first_view, $c->delete_at_day, $c->created_at, $c->created_by, $c->last_access_at, $c->mod_token, $c->nbslices, $c->complete, $c->passwd, $c->abuse, $c->short);
$c->app->dbi->db->query('UPDATE files SET short = ?, deleted = ?, mediatype = ?, filename = ?, filesize = ?, counter = ?, delete_at_first_view = ?, delete_at_day = ?, created_at = ?, created_by = ?, last_access_at = ?, mod_token = ?, nbslices = ?, complete = ?, passwd = ?, abuse = ?, zipped = ? WHERE short = ?', $c->short, $c->deleted, $c->mediatype, $c->filename, $c->filesize, $c->counter, $c->delete_at_first_view, $c->delete_at_day, $c->created_at, $c->created_by, $c->last_access_at, $c->mod_token, $c->nbslices, $c->complete, $c->passwd, $c->abuse, $c->zipped, $c->short);
} else {
$c->app->dbi->db->query('INSERT INTO files (short, deleted, mediatype, filename, filesize, counter, delete_at_first_view, delete_at_day, created_at, created_by, last_access_at, mod_token, nbslices, complete, passwd, abuse) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', $c->short, $c->deleted, $c->mediatype, $c->filename, $c->filesize, $c->counter, $c->delete_at_first_view, $c->delete_at_day, $c->created_at, $c->created_by, $c->last_access_at, $c->mod_token, $c->nbslices, $c->complete, $c->passwd, $c->abuse);
$c->app->dbi->db->query('INSERT INTO files (short, deleted, mediatype, filename, filesize, counter, delete_at_first_view, delete_at_day, created_at, created_by, last_access_at, mod_token, nbslices, complete, passwd, abuse, zipped) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', $c->short, $c->deleted, $c->mediatype, $c->filename, $c->filesize, $c->counter, $c->delete_at_first_view, $c->delete_at_day, $c->created_at, $c->created_by, $c->last_access_at, $c->mod_token, $c->nbslices, $c->complete, $c->passwd, $c->abuse, $c->zipped);
$c->record(1);
}
@ -505,6 +508,7 @@ sub _slurp {
$c->complete($file->{complete});
$c->passwd($file->{passwd});
$c->abuse($file->{abuse});
$c->zipped($file->{zipped});
$c->record(1) unless $c->record;
}

View File

@ -19,9 +19,9 @@ sub register {
# Database migration
my $migrations = Mojo::Pg::Migrations->new(pg => $app->dbi);
if ($app->mode eq 'development' && $ENV{LUFI_DEV}) {
$migrations->from_file('utilities/migrations/pg.sql')->migrate(0)->migrate(2);
$migrations->from_file('utilities/migrations/pg.sql')->migrate(0)->migrate(3);
} else {
$migrations->from_file('utilities/migrations/pg.sql')->migrate(2);
$migrations->from_file('utilities/migrations/pg.sql')->migrate(3);
}
} elsif ($app->config('dbtype') eq 'mysql') {
require Mojo::mysql;
@ -30,9 +30,9 @@ sub register {
# Database migration
my $migrations = Mojo::mysql::Migrations->new(mysql => $app->dbi);
if ($app->mode eq 'development' && $ENV{LUFI_DEV}) {
$migrations->from_file('utilities/migrations/mysql.sql')->migrate(0)->migrate(1);
$migrations->from_file('utilities/migrations/mysql.sql')->migrate(0)->migrate(2);
} else {
$migrations->from_file('utilities/migrations/mysql.sql')->migrate(1);
$migrations->from_file('utilities/migrations/mysql.sql')->migrate(2);
}
} elsif ($app->config('dbtype') eq 'sqlite') {
require Mojo::SQLite;
@ -43,9 +43,9 @@ sub register {
my $sql = $app->dbi;
my $migrations = $sql->migrations;
if ($app->mode eq 'development' && $ENV{LUFI_DEV}) {
$migrations->from_file('utilities/migrations/sqlite.sql')->migrate(0)->migrate(2);
$migrations->from_file('utilities/migrations/sqlite.sql')->migrate(0)->migrate(3);
} else {
$migrations->from_file('utilities/migrations/sqlite.sql')->migrate(2);
$migrations->from_file('utilities/migrations/sqlite.sql')->migrate(3);
}
# Check if passwd column is missing

View File

@ -22,6 +22,7 @@ my $msg = to_json {
"delay" => "0",
"del_at_first_view" => 1,
"id" => undef,
"zipped" => 0,
"i" => 0
};
my $encrypted = '"{\\"iv\\":\\"2RGAviAeYybBqcLCmnqlgA==\\",\\"v\\":1,\\"iter\\":10000,\\"ks\\":128,\\"ts\\":64,\\"mode\\":\\"ccm\\",\\"adata\\":\\"\\",\\"cipher\\":\\"aes\\",\\"salt\\":\\"1dvKtbZ8hxA=\\",\\"ct\\":\\"w9wDZCwNSyH/yL7q1GW5fPSdi+w=\\"}"';

View File

@ -98,15 +98,15 @@ msgstr ""
msgid "Copy to clipboard"
msgstr ""
#: lib/Lufi/Controller/Files.pm:460
#: lib/Lufi/Controller/Files.pm:461
msgid "Could not delete the file. You are not authenticated."
msgstr ""
#: lib/Lufi/Controller/Files.pm:442
#: lib/Lufi/Controller/Files.pm:443
msgid "Could not find the file. Are you sure of the URL and the token?"
msgstr ""
#: lib/Lufi/Controller/Files.pm:353
#: lib/Lufi/Controller/Files.pm:354
msgid "Could not find the file. Are you sure of the URL?"
msgstr ""
@ -170,15 +170,15 @@ msgstr ""
msgid "Encrypting part XX1 of XX2"
msgstr ""
#: lib/Lufi/Controller/Files.pm:242
#: lib/Lufi/Controller/Files.pm:243
msgid "Error: the file existed but was deleted."
msgstr ""
#: lib/Lufi/Controller/Files.pm:322
#: lib/Lufi/Controller/Files.pm:323
msgid "Error: the file has not been sent entirely."
msgstr ""
#: lib/Lufi/Controller/Files.pm:332
#: lib/Lufi/Controller/Files.pm:333
msgid "Error: unable to find the file. Are you sure of your URL?"
msgstr ""
@ -194,7 +194,7 @@ msgstr ""
msgid "Export localStorage data"
msgstr ""
#: lib/Lufi/Controller/Files.pm:424
#: lib/Lufi/Controller/Files.pm:425
msgid "File deleted"
msgstr ""
@ -397,7 +397,7 @@ msgstr ""
msgid "The email subject can't be empty."
msgstr ""
#: lib/Lufi/Controller/Files.pm:421
#: lib/Lufi/Controller/Files.pm:422
msgid "The file has already been deleted"
msgstr ""
@ -422,11 +422,11 @@ msgstr ""
msgid "The original (and only for now) author is <a href=\"https://fiat-tux.fr\" class=\"classic\">Luc Didry</a>."
msgstr ""
#: lib/Lufi/Controller/Files.pm:189
#: lib/Lufi/Controller/Files.pm:190
msgid "The server was unable to find the file record to add your file part to. Please, contact the administrator."
msgstr ""
#: lib/Lufi/Controller/Files.pm:248
#: lib/Lufi/Controller/Files.pm:249
msgid "This file has been deactivated by the admins. Contact them to know why."
msgstr ""
@ -439,17 +439,17 @@ msgid "Unable to copy the link(s) to your clipboard"
msgstr ""
#. ($short)
#: lib/Lufi/Controller/Files.pm:392
#: lib/Lufi/Controller/Files.pm:393
msgid "Unable to get counter for %1. The file does not exists. It will be removed from your localStorage."
msgstr ""
#. ($short)
#: lib/Lufi/Controller/Files.pm:382
#: lib/Lufi/Controller/Files.pm:383
msgid "Unable to get counter for %1. The token is invalid."
msgstr ""
#. ($short)
#: lib/Lufi/Controller/Files.pm:402
#: lib/Lufi/Controller/Files.pm:403
msgid "Unable to get counter for %1. You are not authenticated."
msgstr ""
@ -518,7 +518,7 @@ msgstr ""
msgid "Your file is too big: %1 (maximum size allowed: %2)"
msgstr ""
#: lib/Lufi/Controller/Files.pm:304
#: lib/Lufi/Controller/Files.pm:305
msgid "Your password is not valid. Please refresh the page to retry."
msgstr ""

View File

@ -1,6 +1,6 @@
/*!
JSZip v3.1.5 - A JavaScript class for generating and reading zip files
JSZip v3.2.1 - A JavaScript class for generating and reading zip files
<http://stuartk.com/jszip>
(c) 2009-2016 Stuart Knightley <stuart [at] stuartk.com>
@ -324,7 +324,7 @@ module.exports = {
Promise: ES6Promise
};
},{"lie":58}],7:[function(require,module,exports){
},{"lie":37}],7:[function(require,module,exports){
'use strict';
var USE_TYPEDARRAY = (typeof Uint8Array !== 'undefined') && (typeof Uint16Array !== 'undefined') && (typeof Uint32Array !== 'undefined');
@ -411,7 +411,7 @@ exports.uncompressWorker = function () {
return new FlateWorker("Inflate", {});
};
},{"./stream/GenericWorker":28,"./utils":32,"pako":59}],8:[function(require,module,exports){
},{"./stream/GenericWorker":28,"./utils":32,"pako":38}],8:[function(require,module,exports){
'use strict';
var utils = require('../utils');
@ -1057,7 +1057,7 @@ JSZip.defaults = require('./defaults');
// TODO find a better way to handle this version,
// a require('package.json').version doesn't work with webpack, see #327
JSZip.version = "3.1.5";
JSZip.version = "3.2.0";
JSZip.loadAsync = function (content, options) {
return new JSZip().loadAsync(content, options);
@ -1287,13 +1287,16 @@ module.exports = {
* @return {Buffer} a new Buffer.
*/
newBufferFrom: function(data, encoding) {
// XXX We can't use `Buffer.from` which comes from `Uint8Array.from`
// in nodejs v4 (< v.4.5). It's not the expected implementation (and
// has a different signature).
// see https://github.com/nodejs/node/issues/8053
// A condition on nodejs' version won't solve the issue as we don't
// control the Buffer polyfills that may or may not be used.
return new Buffer(data, encoding);
if (Buffer.from && Buffer.from !== Uint8Array.from) {
return Buffer.from(data, encoding);
} else {
if (typeof data === "number") {
// Safeguard for old Node.js versions. On newer versions,
// Buffer.from(number) / Buffer(number, encoding) already throw.
throw new Error("The \"data\" argument must not be a number");
}
return new Buffer(data, encoding);
}
},
/**
* Create a new nodejs Buffer with the specified size.
@ -1304,7 +1307,9 @@ module.exports = {
if (Buffer.alloc) {
return Buffer.alloc(size);
} else {
return new Buffer(size);
var buf = new Buffer(size);
buf.fill(0);
return buf;
}
},
/**
@ -3032,7 +3037,7 @@ exports.Utf8EncodeWorker = Utf8EncodeWorker;
var support = require('./support');
var base64 = require('./base64');
var nodejsUtils = require('./nodejsUtils');
var setImmediate = require('core-js/library/fn/set-immediate');
var setImmediate = require('set-immediate-shim');
var external = require("./external");
@ -3504,7 +3509,7 @@ exports.prepareContent = function(name, inputData, isBinary, isOptimizedBinarySt
});
};
},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,"core-js/library/fn/set-immediate":36}],33:[function(require,module,exports){
},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,"set-immediate-shim":54}],33:[function(require,module,exports){
'use strict';
var readerFor = require('./reader/readerFor');
var utils = require('./utils');
@ -4198,296 +4203,6 @@ for(var i = 0; i < removedMethods.length; i++) {
module.exports = ZipObject;
},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(require,module,exports){
require('../modules/web.immediate');
module.exports = require('../modules/_core').setImmediate;
},{"../modules/_core":40,"../modules/web.immediate":56}],37:[function(require,module,exports){
module.exports = function(it){
if(typeof it != 'function')throw TypeError(it + ' is not a function!');
return it;
};
},{}],38:[function(require,module,exports){
var isObject = require('./_is-object');
module.exports = function(it){
if(!isObject(it))throw TypeError(it + ' is not an object!');
return it;
};
},{"./_is-object":51}],39:[function(require,module,exports){
var toString = {}.toString;
module.exports = function(it){
return toString.call(it).slice(8, -1);
};
},{}],40:[function(require,module,exports){
var core = module.exports = {version: '2.3.0'};
if(typeof __e == 'number')__e = core; // eslint-disable-line no-undef
},{}],41:[function(require,module,exports){
// optional / simple context binding
var aFunction = require('./_a-function');
module.exports = function(fn, that, length){
aFunction(fn);
if(that === undefined)return fn;
switch(length){
case 1: return function(a){
return fn.call(that, a);
};
case 2: return function(a, b){
return fn.call(that, a, b);
};
case 3: return function(a, b, c){
return fn.call(that, a, b, c);
};
}
return function(/* ...args */){
return fn.apply(that, arguments);
};
};
},{"./_a-function":37}],42:[function(require,module,exports){
// Thank's IE8 for his funny defineProperty
module.exports = !require('./_fails')(function(){
return Object.defineProperty({}, 'a', {get: function(){ return 7; }}).a != 7;
});
},{"./_fails":45}],43:[function(require,module,exports){
var isObject = require('./_is-object')
, document = require('./_global').document
// in old IE typeof document.createElement is 'object'
, is = isObject(document) && isObject(document.createElement);
module.exports = function(it){
return is ? document.createElement(it) : {};
};
},{"./_global":46,"./_is-object":51}],44:[function(require,module,exports){
var global = require('./_global')
, core = require('./_core')
, ctx = require('./_ctx')
, hide = require('./_hide')
, PROTOTYPE = 'prototype';
var $export = function(type, name, source){
var IS_FORCED = type & $export.F
, IS_GLOBAL = type & $export.G
, IS_STATIC = type & $export.S
, IS_PROTO = type & $export.P
, IS_BIND = type & $export.B
, IS_WRAP = type & $export.W
, exports = IS_GLOBAL ? core : core[name] || (core[name] = {})
, expProto = exports[PROTOTYPE]
, target = IS_GLOBAL ? global : IS_STATIC ? global[name] : (global[name] || {})[PROTOTYPE]
, key, own, out;
if(IS_GLOBAL)source = name;
for(key in source){
// contains in native
own = !IS_FORCED && target && target[key] !== undefined;
if(own && key in exports)continue;
// export native or passed
out = own ? target[key] : source[key];
// prevent global pollution for namespaces
exports[key] = IS_GLOBAL && typeof target[key] != 'function' ? source[key]
// bind timers to global for call from export context
: IS_BIND && own ? ctx(out, global)
// wrap global constructors for prevent change them in library
: IS_WRAP && target[key] == out ? (function(C){
var F = function(a, b, c){
if(this instanceof C){
switch(arguments.length){
case 0: return new C;
case 1: return new C(a);
case 2: return new C(a, b);
} return new C(a, b, c);
} return C.apply(this, arguments);
};
F[PROTOTYPE] = C[PROTOTYPE];
return F;
// make static versions for prototype methods
})(out) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out;
// export proto methods to core.%CONSTRUCTOR%.methods.%NAME%
if(IS_PROTO){
(exports.virtual || (exports.virtual = {}))[key] = out;
// export proto methods to core.%CONSTRUCTOR%.prototype.%NAME%
if(type & $export.R && expProto && !expProto[key])hide(expProto, key, out);
}
}
};
// type bitmap
$export.F = 1; // forced
$export.G = 2; // global
$export.S = 4; // static
$export.P = 8; // proto
$export.B = 16; // bind
$export.W = 32; // wrap
$export.U = 64; // safe
$export.R = 128; // real proto method for `library`
module.exports = $export;
},{"./_core":40,"./_ctx":41,"./_global":46,"./_hide":47}],45:[function(require,module,exports){
module.exports = function(exec){
try {
return !!exec();
} catch(e){
return true;
}
};
},{}],46:[function(require,module,exports){
// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
var global = module.exports = typeof window != 'undefined' && window.Math == Math
? window : typeof self != 'undefined' && self.Math == Math ? self : Function('return this')();
if(typeof __g == 'number')__g = global; // eslint-disable-line no-undef
},{}],47:[function(require,module,exports){
var dP = require('./_object-dp')
, createDesc = require('./_property-desc');
module.exports = require('./_descriptors') ? function(object, key, value){
return dP.f(object, key, createDesc(1, value));
} : function(object, key, value){
object[key] = value;
return object;
};
},{"./_descriptors":42,"./_object-dp":52,"./_property-desc":53}],48:[function(require,module,exports){
module.exports = require('./_global').document && document.documentElement;
},{"./_global":46}],49:[function(require,module,exports){
module.exports = !require('./_descriptors') && !require('./_fails')(function(){
return Object.defineProperty(require('./_dom-create')('div'), 'a', {get: function(){ return 7; }}).a != 7;
});
},{"./_descriptors":42,"./_dom-create":43,"./_fails":45}],50:[function(require,module,exports){
// fast apply, http://jsperf.lnkit.com/fast-apply/5
module.exports = function(fn, args, that){
var un = that === undefined;
switch(args.length){
case 0: return un ? fn()
: fn.call(that);
case 1: return un ? fn(args[0])
: fn.call(that, args[0]);
case 2: return un ? fn(args[0], args[1])
: fn.call(that, args[0], args[1]);
case 3: return un ? fn(args[0], args[1], args[2])
: fn.call(that, args[0], args[1], args[2]);
case 4: return un ? fn(args[0], args[1], args[2], args[3])
: fn.call(that, args[0], args[1], args[2], args[3]);
} return fn.apply(that, args);
};
},{}],51:[function(require,module,exports){
module.exports = function(it){
return typeof it === 'object' ? it !== null : typeof it === 'function';
};
},{}],52:[function(require,module,exports){
var anObject = require('./_an-object')
, IE8_DOM_DEFINE = require('./_ie8-dom-define')
, toPrimitive = require('./_to-primitive')
, dP = Object.defineProperty;
exports.f = require('./_descriptors') ? Object.defineProperty : function defineProperty(O, P, Attributes){
anObject(O);
P = toPrimitive(P, true);
anObject(Attributes);
if(IE8_DOM_DEFINE)try {
return dP(O, P, Attributes);
} catch(e){ /* empty */ }
if('get' in Attributes || 'set' in Attributes)throw TypeError('Accessors not supported!');
if('value' in Attributes)O[P] = Attributes.value;
return O;
};
},{"./_an-object":38,"./_descriptors":42,"./_ie8-dom-define":49,"./_to-primitive":55}],53:[function(require,module,exports){
module.exports = function(bitmap, value){
return {
enumerable : !(bitmap & 1),
configurable: !(bitmap & 2),
writable : !(bitmap & 4),
value : value
};
};
},{}],54:[function(require,module,exports){
var ctx = require('./_ctx')
, invoke = require('./_invoke')
, html = require('./_html')
, cel = require('./_dom-create')
, global = require('./_global')
, process = global.process
, setTask = global.setImmediate
, clearTask = global.clearImmediate
, MessageChannel = global.MessageChannel
, counter = 0
, queue = {}
, ONREADYSTATECHANGE = 'onreadystatechange'
, defer, channel, port;
var run = function(){
var id = +this;
if(queue.hasOwnProperty(id)){
var fn = queue[id];
delete queue[id];
fn();
}
};
var listener = function(event){
run.call(event.data);
};
// Node.js 0.9+ & IE10+ has setImmediate, otherwise:
if(!setTask || !clearTask){
setTask = function setImmediate(fn){
var args = [], i = 1;
while(arguments.length > i)args.push(arguments[i++]);
queue[++counter] = function(){
invoke(typeof fn == 'function' ? fn : Function(fn), args);
};
defer(counter);
return counter;
};
clearTask = function clearImmediate(id){
delete queue[id];
};
// Node.js 0.8-
if(require('./_cof')(process) == 'process'){
defer = function(id){
process.nextTick(ctx(run, id, 1));
};
// Browsers with MessageChannel, includes WebWorkers
} else if(MessageChannel){
channel = new MessageChannel;
port = channel.port2;
channel.port1.onmessage = listener;
defer = ctx(port.postMessage, port, 1);
// Browsers with postMessage, skip WebWorkers
// IE8 has postMessage, but it's sync & typeof its postMessage is 'object'
} else if(global.addEventListener && typeof postMessage == 'function' && !global.importScripts){
defer = function(id){
global.postMessage(id + '', '*');
};
global.addEventListener('message', listener, false);
// IE8-
} else if(ONREADYSTATECHANGE in cel('script')){
defer = function(id){
html.appendChild(cel('script'))[ONREADYSTATECHANGE] = function(){
html.removeChild(this);
run.call(id);
};
};
// Rest old browsers
} else {
defer = function(id){
setTimeout(ctx(run, id, 1), 0);
};
}
}
module.exports = {
set: setTask,
clear: clearTask
};
},{"./_cof":39,"./_ctx":41,"./_dom-create":43,"./_global":46,"./_html":48,"./_invoke":50}],55:[function(require,module,exports){
// 7.1.1 ToPrimitive(input [, PreferredType])
var isObject = require('./_is-object');
// instead of the ES6 spec version, we didn't implement @@toPrimitive case
// and the second argument - flag - preferred type is a string
module.exports = function(it, S){
if(!isObject(it))return it;
var fn, val;
if(S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it)))return val;
if(typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it)))return val;
if(!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it)))return val;
throw TypeError("Can't convert object to primitive value");
};
},{"./_is-object":51}],56:[function(require,module,exports){
var $export = require('./_export')
, $task = require('./_task');
$export($export.G + $export.B, {
setImmediate: $task.set,
clearImmediate: $task.clear
});
},{"./_export":44,"./_task":54}],57:[function(require,module,exports){
(function (global){
'use strict';
var Mutation = global.MutationObserver || global.WebKitMutationObserver;
@ -4560,7 +4275,7 @@ function immediate(task) {
}
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{}],58:[function(require,module,exports){
},{}],37:[function(require,module,exports){
'use strict';
var immediate = require('immediate');
@ -4587,6 +4302,26 @@ function Promise(resolver) {
}
}
Promise.prototype["finally"] = function (callback) {
if (typeof callback !== 'function') {
return this;
}
var p = this.constructor;
return this.then(resolve, reject);
function resolve(value) {
function yes () {
return value;
}
return p.resolve(callback()).then(yes);
}
function reject(reason) {
function no () {
throw reason;
}
return p.resolve(callback()).then(no);
}
};
Promise.prototype["catch"] = function (onRejected) {
return this.then(null, onRejected);
};
@ -4815,7 +4550,7 @@ function race(iterable) {
}
}
},{"immediate":57}],59:[function(require,module,exports){
},{"immediate":36}],38:[function(require,module,exports){
// Top level file is just a mixin of submodules & constants
'use strict';
@ -4831,7 +4566,7 @@ assign(pako, deflate, inflate, constants);
module.exports = pako;
},{"./lib/deflate":60,"./lib/inflate":61,"./lib/utils/common":62,"./lib/zlib/constants":65}],60:[function(require,module,exports){
},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(require,module,exports){
'use strict';
@ -5233,7 +4968,7 @@ exports.deflate = deflate;
exports.deflateRaw = deflateRaw;
exports.gzip = gzip;
},{"./utils/common":62,"./utils/strings":63,"./zlib/deflate":67,"./zlib/messages":72,"./zlib/zstream":74}],61:[function(require,module,exports){
},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(require,module,exports){
'use strict';
@ -5653,7 +5388,7 @@ exports.inflate = inflate;
exports.inflateRaw = inflateRaw;
exports.ungzip = inflate;
},{"./utils/common":62,"./utils/strings":63,"./zlib/constants":65,"./zlib/gzheader":68,"./zlib/inflate":70,"./zlib/messages":72,"./zlib/zstream":74}],62:[function(require,module,exports){
},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(require,module,exports){
'use strict';
@ -5757,7 +5492,7 @@ exports.setTyped = function (on) {
exports.setTyped(TYPED_OK);
},{}],63:[function(require,module,exports){
},{}],42:[function(require,module,exports){
// String encode/decode helpers
'use strict';
@ -5944,7 +5679,7 @@ exports.utf8border = function (buf, max) {
return (pos + _utf8len[buf[pos]] > max) ? pos : max;
};
},{"./common":62}],64:[function(require,module,exports){
},{"./common":41}],43:[function(require,module,exports){
'use strict';
// Note: adler32 takes 12% for level 0 and 2% for level 6.
@ -5997,7 +5732,7 @@ function adler32(adler, buf, len, pos) {
module.exports = adler32;
},{}],65:[function(require,module,exports){
},{}],44:[function(require,module,exports){
'use strict';
// (C) 1995-2013 Jean-loup Gailly and Mark Adler
@ -6067,7 +5802,7 @@ module.exports = {
//Z_NULL: null // Use -1 or null inline, depending on var type
};
},{}],66:[function(require,module,exports){
},{}],45:[function(require,module,exports){
'use strict';
// Note: we can't get significant speed boost here.
@ -6128,7 +5863,7 @@ function crc32(crc, buf, len, pos) {
module.exports = crc32;
},{}],67:[function(require,module,exports){
},{}],46:[function(require,module,exports){
'use strict';
// (C) 1995-2013 Jean-loup Gailly and Mark Adler
@ -8004,7 +7739,7 @@ exports.deflatePrime = deflatePrime;
exports.deflateTune = deflateTune;
*/
},{"../utils/common":62,"./adler32":64,"./crc32":66,"./messages":72,"./trees":73}],68:[function(require,module,exports){
},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(require,module,exports){
'use strict';
// (C) 1995-2013 Jean-loup Gailly and Mark Adler
@ -8064,7 +7799,7 @@ function GZheader() {
module.exports = GZheader;
},{}],69:[function(require,module,exports){
},{}],48:[function(require,module,exports){
'use strict';
// (C) 1995-2013 Jean-loup Gailly and Mark Adler
@ -8411,7 +8146,7 @@ module.exports = function inflate_fast(strm, start) {
return;
};
},{}],70:[function(require,module,exports){
},{}],49:[function(require,module,exports){
'use strict';
// (C) 1995-2013 Jean-loup Gailly and Mark Adler
@ -9969,7 +9704,7 @@ exports.inflateSyncPoint = inflateSyncPoint;
exports.inflateUndermine = inflateUndermine;
*/
},{"../utils/common":62,"./adler32":64,"./crc32":66,"./inffast":69,"./inftrees":71}],71:[function(require,module,exports){
},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(require,module,exports){
'use strict';
// (C) 1995-2013 Jean-loup Gailly and Mark Adler
@ -10314,7 +10049,7 @@ module.exports = function inflate_table(type, lens, lens_index, codes, table, ta
return 0;
};
},{"../utils/common":62}],72:[function(require,module,exports){
},{"../utils/common":41}],51:[function(require,module,exports){
'use strict';
// (C) 1995-2013 Jean-loup Gailly and Mark Adler
@ -10348,7 +10083,7 @@ module.exports = {
'-6': 'incompatible version' /* Z_VERSION_ERROR (-6) */
};
},{}],73:[function(require,module,exports){
},{}],52:[function(require,module,exports){
'use strict';
// (C) 1995-2013 Jean-loup Gailly and Mark Adler
@ -11570,7 +11305,7 @@ exports._tr_flush_block = _tr_flush_block;
exports._tr_tally = _tr_tally;
exports._tr_align = _tr_align;
},{"../utils/common":62}],74:[function(require,module,exports){
},{"../utils/common":41}],53:[function(require,module,exports){
'use strict';
// (C) 1995-2013 Jean-loup Gailly and Mark Adler
@ -11619,5 +11354,14 @@ function ZStream() {
module.exports = ZStream;
},{}],54:[function(require,module,exports){
'use strict';
module.exports = typeof setImmediate === 'function' ? setImmediate :
function setImmediate() {
var args = [].slice.apply(arguments);
args.splice(1, 0, 0);
setTimeout.apply(null, args);
};
},{}]},{},[10])(10)
});

File diff suppressed because one or more lines are too long

View File

@ -106,7 +106,7 @@ function spawnWebsocket(pa) {
}
var innerHTML = ['<p><a href="', blobURL, '" class="btn btn-primary" download="', escapeHtml(data.name), '">', i18n.download, '</a></p>'];
var isZip = false;
var isZip = ($('#filesize').attr('data-zipped') === 'true');
if (data.type.match(/^image\//) !== null) {
innerHTML.push('<img id="render-image" class="responsive-img" alt="', escapeHtml(data.name), '" src="', blobURL, '">');
} else if (data.type.match(/^video\//) !== null) {
@ -117,9 +117,8 @@ function spawnWebsocket(pa) {
innerHTML.push('<audio class="responsive-video" controls>',
'<source src="', blobURL, '" type="', data.type, '">',
'</audio>');
} else if (data.type.match(/^application\/zip/) !== null) {
} else if (isZip) {
innerHTML.push('<p><a class="btn btn-primary" id="showZipContent">', i18n.showZipContent, '</a></p>');
isZip = true;
}
pbd.html(innerHTML.join(''));
@ -130,10 +129,28 @@ function spawnWebsocket(pa) {
.then(function (zip) {
var innerHTML = ['<h3>Zip content:</h3><ul>'];
zip.forEach(function (relativePath, zipEntry) {
innerHTML.push('<li>', zipEntry.name, ' (', filesize(zipEntry._data.uncompressedSize, {base: 10}), ')</li>');
innerHTML.push(
'<li>',
zipEntry.name,
' (', filesize(zipEntry._data.uncompressedSize, {base: 10}), ') ',
'<a href="#" download="', zipEntry.name, '" class="download-zip-content" title="', i18n.download, '">',
'<i class="mdi-file-file-download"></i>',
'</a>',
'</li>'
);
});
innerHTML.push('</ul>');
pbd.append(innerHTML.join(''));
$('.download-zip-content').click(function(e) {
e.preventDefault();
var t = $(this);
var filename = t.attr('download');
zip.files[filename].async('blob').then(function(blob) {
t.unbind('click');
t.attr('href', URL.createObjectURL(blob));
t[0].click();
});
})
$('#showZipContent').hide();
$('#showZipContent').unbind('click');
});

View File

@ -113,7 +113,7 @@ function handleFiles(f) {
$('#zipping').show();
for (var i = 0; i < f.length; i++) {
var element = f.item(i);
zip.file(element.name, new Blob([element]));
zip.file(element.name, element);
}
zip.generateAsync({type:"blob"})
.then(function(zipFile) {
@ -222,6 +222,7 @@ function sliceAndUpload(randomkey, i, parts, j, delay, del_at_first_view, short)
type: file.type,
delay: delay,
del_at_first_view: del_at_first_view,
zipped: $('#zip-files').is(':checked'),
id: short,
// number of the sent file in the queue
i: i

View File

@ -29,7 +29,7 @@
</div>
% }
<div class="file-progress col s12<%= (stash('file_pwd')) ? ' hide' : '' %>">
<p id="filesize" data-filesize="<%= stash('f')->filesize %>"></p>
<p id="filesize" data-filesize="<%= stash('f')->filesize %>" data-zipped="<%= (stash('f')->zipped) ? 'true' : 'false' %>"></p>
<p id="please-wait"><%= l('Please wait while we are getting your file. We first need to download and decrypt all parts before you can get it.') %></p>
<p id="loading"></p>
<div class="progress" id="pbd">

View File

@ -27,3 +27,7 @@ CREATE TABLE IF NOT EXISTS slices (
-- 1 down
DROP TABLE slices;
DROP TABLE files;
-- 2 up
ALTER TABLE files ADD COLUMN zipped boolean default false;
-- 2 down
ALTER TABLE files DROP COLUMN zipped;

View File

@ -30,3 +30,7 @@ DROP TABLE files;
ALTER TABLE files ADD COLUMN abuse integer;
-- 2 down
ALTER TABLE files DROP COLUMN abuse;
-- 3 up
ALTER TABLE files ADD COLUMN zipped boolean default false;
-- 3 down
ALTER TABLE files DROP COLUMN zipped;

View File

@ -52,3 +52,29 @@ BEGIN TRANSACTION;
DROP TABLE files;
ALTER TABLE files_backup RENAME TO files;
COMMIT;
-- 3 up
ALTER TABLE files ADD COLUMN zipped INTEGER;
-- 3 down
BEGIN TRANSACTION;
CREATE TABLE files_backup (
short TEXT PRIMARY KEY,
deleted INTEGER,
mediatype TEXT,
filename TEXT,
filesize INTEGER,
counter INTEGER,
delete_at_first_view INTEGER,
delete_at_day INTEGER,
created_at INTEGER,
created_by TEXT,
last_access_at INTEGER,
mod_token TEXT,
nbslices INTEGER,
complete INTEGER,
passwd TEXT,
abuse INTEGER
);
INSERT INTO files_backup SELECT short, deleted, mediatype, filename, filesize, counter, delete_at_first_view, delete_at_day, created_at, created_by, last_access_at, mod_token, nbslices, complete, passwd, abuse FROM files;
DROP TABLE files;
ALTER TABLE files_backup RENAME TO files;
COMMIT;