This commit is contained in:
Alan K 2014-12-17 02:35:01 -05:00
parent 5798beb99f
commit 2b6d54cbf4
4 changed files with 107 additions and 9 deletions

View File

@ -1,6 +1,6 @@
{
"name": "filer",
"version": "0.0.36",
"version": "0.0.37",
"main": "dist/filer.js",
"ignore": [
"build",

104
dist/filer.js vendored
View File

@ -5890,7 +5890,88 @@ function rename(fs, context, oldpath, newpath, callback) {
if(!pathCheck(oldpath, callback)) return;
if(!pathCheck(newpath, callback)) return;
function unlink_old_node(error) {
var oldParentPath = Path.dirname(oldpath);
var newParentPath = Path.dirname(oldpath);
var oldName = Path.basename(oldpath);
var newName = Path.basename(newpath);
var oldParentDirectory, oldParentData;
var newParentDirectory, newParentData;
function update_times(error, newNode) {
if(error) {
callback(error);
} else {
update_node_times(context, newpath, newNode, { ctime: Date.now() }, callback);
}
}
function read_new_directory(error) {
if(error) {
callback(error);
} else {
context.getObject(newParentData[newName].id, update_times);
}
}
function update_old_parent_directory_data(error) {
if(error) {
callback(error);
} else {
delete oldParentData[oldName];
context.putObject(oldParentDirectory.data, oldParentData, read_new_directory);
}
}
function update_new_parent_directory_data(error) {
if(error) {
callback(error);
} else {
newParentData[newName] = oldParentData[oldName];
context.putObject(newParentDirectory.data, newParentData, update_old_parent_directory_data);
}
}
function check_if_new_directory_exists(error, result) {
if(error) {
callback(error);
} else {
newParentData = result;
if(_(newParentData).has(newName)) {
remove_directory(context, newpath, update_new_parent_directory_data);
} else {
update_new_parent_directory_data();
}
}
}
function read_new_parent_directory_data(error, result) {
if(error) {
callback(error);
} else {
newParentDirectory = result;
context.getObject(newParentDirectory.data, check_if_new_directory_exists);
}
}
function get_new_parent_directory(error, result) {
if(error) {
callback(error);
} else {
oldParentData = result;
find_node(context, newParentPath, read_new_parent_directory_data);
}
}
function read_parent_directory_data(error, result) {
if(error) {
callback(error);
} else {
oldParentDirectory = result;
context.getObject(result.data, get_new_parent_directory);
}
}
function unlink_old_file(error) {
if(error) {
callback(error);
} else {
@ -5898,7 +5979,17 @@ function rename(fs, context, oldpath, newpath, callback) {
}
}
link_node(context, oldpath, newpath, unlink_old_node);
function check_node_type(error, node) {
if(error) {
callback(error);
} else if(node.mode === 'DIRECTORY') {
find_node(context, oldParentPath, read_parent_directory_data);
} else {
link_node(context, oldpath, newpath, unlink_old_file);
}
}
find_node(context, oldpath, check_node_type);
}
function symlink(fs, context, srcpath, dstpath, type, callback) {
@ -6030,6 +6121,13 @@ function maybeCallback(callback) {
};
}
// Default callback that logs an error if passed in
function defaultCallback(err) {
if(err) {
console.error('Filer error: ', err);
}
}
/**
* FileSystem
*
@ -6060,7 +6158,7 @@ function maybeCallback(callback) {
*/
function FileSystem(options, callback) {
options = options || {};
callback = callback || nop;
callback = callback || defaultCallback;
var flags = options.flags;
var guid = options.guid ? options.guid : defaultGuidFn;

8
dist/filer.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -11,7 +11,7 @@
"idb",
"websql"
],
"version": "0.0.36",
"version": "0.0.37",
"author": "Alan K <ack@modeswitch.org> (http://blog.modeswitch.org)",
"homepage": "http://filerjs.github.io/filer",
"bugs": "https://github.com/filerjs/filer/issues",