Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: lib/filesystem/io.js

Issue 5113028861231104: Issue 361 - patterns.ini cleared when writing to file got interrupted (Closed)
Patch Set: Created April 28, 2014, 8:47 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/filesystem/io.js
===================================================================
--- a/lib/filesystem/io.js
+++ b/lib/filesystem/io.js
@@ -107,25 +107,26 @@
op();
}.bind(this);
- executeWriteOperation(writer.truncate.bind(writer, 0), function()
+ var blob;
+
+ try
{
- var blob;
- try
- {
- blob = new Blob([data.join(this.lineBreak) + this.lineBreak], {type: "text/plain"});
- }
- catch (e)
- {
- if (!(e instanceof TypeError))
- throw e;
+ 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");
- }
- executeWriteOperation(writer.write.bind(writer, blob), callback.bind(null, null));
- }.bind(this));
+ // 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");
+ }
+ executeWriteOperation(writer.write.bind(writer, blob), function()
+ {
+ executeWriteOperation(writer.truncate.bind(writer, writer.position), callback.bind(null, null));
+ });
}.bind(this), callback);
}.bind(this), callback);
},
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld