condo 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/app/assets/javascripts/condo/md5/hasher.js +34 -7
- data/lib/condo/version.rb +1 -1
- metadata +1 -1
@@ -2,7 +2,17 @@
|
|
2
2
|
|
3
3
|
var CondoMD5Hasher = (function(global) {
|
4
4
|
|
5
|
-
var part_size = 1048576
|
5
|
+
var part_size = 1048576, // This is the amount of the file we read into memory as we are building the hash (1mb)
|
6
|
+
async = true;
|
7
|
+
|
8
|
+
//
|
9
|
+
// Firefox does not have FileReader in webworkers? WTF
|
10
|
+
// See issue #2
|
11
|
+
//
|
12
|
+
if (!!!global.FileReader) {
|
13
|
+
async = false;
|
14
|
+
global.FileReader = global.FileReaderSync;
|
15
|
+
}
|
6
16
|
|
7
17
|
return function(callback) {
|
8
18
|
|
@@ -14,7 +24,7 @@ var CondoMD5Hasher = (function(global) {
|
|
14
24
|
|
15
25
|
var current_part,
|
16
26
|
md5 = new global.SparkMD5(),
|
17
|
-
reader = new FileReader(),
|
27
|
+
reader = new global.FileReader(),
|
18
28
|
part_number = 0,
|
19
29
|
length = Math.ceil(blob.size / part_size),
|
20
30
|
fail = function() {
|
@@ -49,13 +59,30 @@ var CondoMD5Hasher = (function(global) {
|
|
49
59
|
current_part = blob;
|
50
60
|
}
|
51
61
|
|
52
|
-
|
62
|
+
if(async)
|
63
|
+
reader.readAsArrayBuffer(current_part);
|
64
|
+
else {
|
65
|
+
setTimeout(function() {
|
66
|
+
try {
|
67
|
+
hashData({
|
68
|
+
target: {
|
69
|
+
result: reader.readAsArrayBuffer(current_part)
|
70
|
+
}
|
71
|
+
});
|
72
|
+
} catch (e) {
|
73
|
+
fail();
|
74
|
+
}
|
75
|
+
}, 1);
|
76
|
+
}
|
77
|
+
|
53
78
|
};
|
54
79
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
80
|
+
|
81
|
+
if(async) {
|
82
|
+
reader.onload = hashData;
|
83
|
+
reader.onerror = fail;
|
84
|
+
reader.onabort = fail;
|
85
|
+
}
|
59
86
|
|
60
87
|
|
61
88
|
processPart();
|
data/lib/condo/version.rb
CHANGED