From 155a8620b371f05624b527925064c73f351661b7 Mon Sep 17 00:00:00 2001 From: Klever Loza Vega Date: Mon, 30 Mar 2015 18:50:02 -0400 Subject: [PATCH] updated filesystem to work with two servers --- src/filesystem/File.js | 11 +++++++- src/filesystem/impls/filer/FilerFileSystem.js | 28 +++++++++++++------ src/filesystem/impls/lib/default.html | 10 +++++++ 3 files changed, 39 insertions(+), 10 deletions(-) create mode 100644 src/filesystem/impls/lib/default.html diff --git a/src/filesystem/File.js b/src/filesystem/File.js index 407ac94cd42..4c60e05f751 100644 --- a/src/filesystem/File.js +++ b/src/filesystem/File.js @@ -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"); /* @@ -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) { diff --git a/src/filesystem/impls/filer/FilerFileSystem.js b/src/filesystem/impls/filer/FilerFileSystem.js index cb94bf0df5e..8db68a933b7 100644 --- a/src/filesystem/impls/filer/FilerFileSystem.js +++ b/src/filesystem/impls/filer/FilerFileSystem.js @@ -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, @@ -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(); + } }); } diff --git a/src/filesystem/impls/lib/default.html b/src/filesystem/impls/lib/default.html new file mode 100644 index 00000000000..f752e3afedf --- /dev/null +++ b/src/filesystem/impls/lib/default.html @@ -0,0 +1,10 @@ + + + + + + + +

New HTML File

+ +