Skip to content

Commit

Permalink
updated filesystem to work with two servers
Browse files Browse the repository at this point in the history
  • Loading branch information
K-LV committed Mar 31, 2015
1 parent 98f8622 commit 155a862
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 10 deletions.
11 changes: 10 additions & 1 deletion src/filesystem/File.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@
define(function (require, exports, module) {
"use strict";

var FileSystemEntry = require("filesystem/FileSystemEntry");
var FileSystemEntry = require("filesystem/FileSystemEntry"),
Content = require("extensions/default/brackets-browser-livedev/nohost/src/content"),
Path = require("filesystem/impls/filer/BracketsFiler").Path,
defaultHTML = require("text!filesystem/impls/lib/default.html");


/*
Expand Down Expand Up @@ -145,6 +148,12 @@ define(function (require, exports, module) {

callback = callback || function () {};
}

// If the file is of type HTML and it's empty
// change the content to be that of a default HTML file
if(Content.isHTML(Path.extname(this._path)) && data === "") {
data = defaultHTML;
}

// Request a consistency check if the write is not blind
if (!options.blind) {
Expand Down
28 changes: 19 additions & 9 deletions src/filesystem/impls/filer/FilerFileSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ define(function (require, exports, module) {
FileSystemStats = require("filesystem/FileSystemStats"),
Filer = require("filesystem/impls/filer/BracketsFiler"),
Dialog = require("thirdparty/filer-dialogs/filer-dialogs"),
BlobUtils = require("filesystem/impls/filer/BlobUtils");
BlobUtils = require("filesystem/impls/filer/BlobUtils"),
Content = require("extensions/default/brackets-browser-livedev/nohost/src/content");

var fs = Filer.fs(),
Path = Filer.Path,
Expand Down Expand Up @@ -227,17 +228,26 @@ define(function (require, exports, module) {
return;
}

// Add a BLOB cache record for this filename
BlobUtils.cache(path, function(err) {
if(err) {
callback(_mapError(err));
return;
}

function doStat() {
stat(path, function (err, stat) {
callback(_mapError(err), stat, created);
});
});
}

// Add a BLOB cache record for this filename
// only if it's not an HTML file
if(!Content.isHTML(Path.extname(path))) {
BlobUtils.cache(path, function(err) {
if(err) {
callback(_mapError(err));
return;
}

doStat();
});
} else {
doStat();
}
});
}

Expand Down
10 changes: 10 additions & 0 deletions src/filesystem/impls/lib/default.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<p>New HTML File</p>
</body>
</html>

0 comments on commit 155a862

Please sign in to comment.