condo 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,17 @@
2
2
 
3
3
  var CondoMD5Hasher = (function(global) {
4
4
 
5
- var part_size = 1048576; // This is the amount of the file we read into memory as we are building the hash (1mb)
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
- reader.readAsArrayBuffer(current_part);
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
- reader.onload = hashData;
57
- reader.onerror = fail;
58
- reader.onabort = fail;
80
+
81
+ if(async) {
82
+ reader.onload = hashData;
83
+ reader.onerror = fail;
84
+ reader.onabort = fail;
85
+ }
59
86
 
60
87
 
61
88
  processPart();
@@ -1,3 +1,3 @@
1
1
  module Condo
2
- VERSION = "1.0.2"
2
+ VERSION = "1.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: condo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: