Index: lib/adblockplus_compat.js |
=================================================================== |
--- a/lib/adblockplus_compat.js |
+++ b/lib/adblockplus_compat.js |
@@ -174,39 +174,49 @@ require.scopes.io = |
{ |
this._getFileEntry(file, true, function(fs, fileEntry) |
{ |
fileEntry.createWriter(function(writer) |
{ |
writer.onwriteend = function() |
{ |
if (writer.error) |
+ { |
callback(writer.error); |
- else |
- callback(null); |
- }; |
+ return; |
+ } |
- var blob; |
- try |
- { |
- blob = new Blob([data.join("\n") + "\n"], {type: "text/plain"}); |
- } |
- catch (e) |
- { |
- if (!(e instanceof TypeError)) |
- throw e; |
+ writer.onwriteend = function() |
+ { |
+ if (writer.error) |
+ callback(writer.error); |
+ else |
+ callback(null); |
+ }.bind(this); |
- // Blob wasn't a constructor before Chrome 20 |
- var builder = new (window.BlobBuilder || window.WebKitBlobBuilder); |
- builder.append(data.join("\n") + "\n"); |
- blob = builder.getBlob("text/plain"); |
- } |
- writer.write(blob); |
- }, callback); |
- }, callback); |
+ var blob; |
+ try |
+ { |
+ blob = new Blob([data.join(this.lineBreak) + this.lineBreak], {type: "text/plain"}); |
+ } |
+ catch (e) |
+ { |
+ if (!(e instanceof TypeError)) |
+ throw e; |
+ |
+ // Blob wasn't a constructor before Chrome 20 |
+ var builder = new (window.BlobBuilder || window.WebKitBlobBuilder); |
+ builder.append(data.join(this.lineBreak) + this.lineBreak); |
+ blob = builder.getBlob("text/plain"); |
+ } |
+ writer.write(blob); |
+ }.bind(this); |
+ writer.truncate(0); |
+ }.bind(this), callback); |
+ }.bind(this), callback); |
}, |
copyFile: function(fromFile, toFile, callback) |
{ |
// Simply combine read and write operations |
var data = []; |
this.readFromFile(fromFile, false, { |
process: function(line) |