Skip to content
Permalink
Browse files

Fixed bug with folder display on dashboard for deleted files

  • Loading branch information...
davidmerfield committed Mar 13, 2019
1 parent e31a149 commit 23ec76383432e9591ab83bf14b08e4a90800129e
Showing with 13 additions and 19 deletions.
  1. +13 −19 app/dashboard/routes/folder/renderFolder.js
@@ -1,13 +1,12 @@
var stat = require("./stat");
var fs = require("fs-extra");
var join = require("path").join;
var async = require('async');
var async = require("async");
var blog_folder_dir = require("config").blog_folder_dir;
var stat = require("./stat");
var alphanum = require('./alphanum');
var alphanum = require("./alphanum");

module.exports = function(req, res, next) {

var dir = req.dir;
var localPath = join(blog_folder_dir, req.blog.id, dir);
var files = [];
@@ -39,17 +38,18 @@ module.exports = function(req, res, next) {
if (err) return next(err);
fs.readdir(localPath, render);
});
}

}

// If the user has the Dropbox client, case-preserved folder
// is stored lowercase on disk. So we check that too.
if (err && err.code === "ENOENT" && dir.toLowerCase() !== dir) {
dir = dir.toLowerCase();
localPath = join(blog_folder_dir, req.blog.id, dir);
return fs.readdir(localPath, render);
}

if (err && err.code === "ENOENT") {
return fs.readdir(join(blog_folder_dir, req.blog.id), render)
return fs.readdir(join(blog_folder_dir, req.blog.id), render);
}

if (err) {
@@ -58,30 +58,24 @@ module.exports = function(req, res, next) {

contents = contents.filter(function(name) {
// hide dotfiles
return name[0] !== "." &&

// hide preview files
name.slice(-'.preview.html'.length) !== '.preview.html';
return (
name[0] !== "." &&
// hide preview files
name.slice(-".preview.html".length) !== ".preview.html"
);
});

contents = contents.map(function(name) {
return join(dir, name);
});


async.eachLimit(contents, 10, load, function() {

folders = alphanum(folders, {property: 'name'});
files = alphanum(files, {property: 'name'});
folders = alphanum(folders, { property: "name" });
files = alphanum(files, { property: "name" });

res.locals.folder.contents = folders.concat(files);
res.locals.folder.directory = true;
next();
});
});
};
function alphabeticallyByName (a, b) {
var aName = a.name.toUpperCase();
var bName = b.name.toUpperCase();
return (aName < bName) ? -1 : (aName > bName) ? 1 : 0;
}

0 comments on commit 23ec763

Please sign in to comment.
You can’t perform that action at this time.