From 5438d8c97b262936eb689cc51990d244560179dd Mon Sep 17 00:00:00 2001 From: "David Humphrey (:humph) david.humphrey@senecacollege.ca" Date: Wed, 5 Mar 2014 20:03:27 -0500 Subject: [PATCH] Fix mount flags per review and also write docs --- README.md | 7 +++++-- src/constants.js | 7 ++++--- src/fs.js | 8 ++++---- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index fc130e2..877cb4e 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,10 @@ Accepts two arguments: an `options` object, and an optional `callback`. The `opt object can specify a number of optional arguments, including: * `name`: the name of the file system, defaults to `'"local'` -* `flags`: one or more flags to use when creating/opening the file system. Use `'FORMAT'` to force Filer to format (i.e., erase) the file system +* `flags`: an Array of one or more flags to use when creating/opening the file system: + *`'FORMAT'` to force Filer to format (i.e., erase) the file system + *`'NOCTIME'` to force Filer to not update `ctime` on nodes when metadata changes (i.e., for better performance) + *`'NOMTIME'` to force Filer to not update `mtime` on nodes when data changes (i.e., for better performance) * `provider`: an explicit storage provider to use for the file system's database context provider. See the section on [Storage Providers](#providers). The `callback` function indicates when the file system is ready for use. Depending on the storage provider used, this might @@ -98,7 +101,7 @@ function fsReady(err, fs) { fs = new Filer.FileSystem({ name: "my-filesystem", - flags: 'FORMAT', + flags: [ 'FORMAT' ], provider: new Filer.FileSystem.providers.Memory() }, fsReady); ``` diff --git a/src/constants.js b/src/constants.js index 56a510a..660810f 100644 --- a/src/constants.js +++ b/src/constants.js @@ -33,8 +33,12 @@ define(function(require) { ROOT_DIRECTORY_NAME: '/', // basename(normalize(path)) + // FS Mount Flags FS_FORMAT: 'FORMAT', + FS_NOCTIME: 'NOCTIME', + FS_NOMTIME: 'NOMTIME', + // FS File Open Flags O_READ: O_READ, O_WRITE: O_WRITE, O_CREATE: O_CREATE, @@ -58,9 +62,6 @@ define(function(require) { XATTR_CREATE: XATTR_CREATE, XATTR_REPLACE: XATTR_REPLACE, - NOCTIME: 'NOCTIME', - NOMTIME: 'NOMTIME', - FS_READY: 'READY', FS_PENDING: 'PENDING', FS_ERROR: 'ERROR', diff --git a/src/fs.js b/src/fs.js index b16376a..b5662eb 100644 --- a/src/fs.js +++ b/src/fs.js @@ -52,8 +52,8 @@ define(function(require) { var O_FLAGS = require('src/constants').O_FLAGS; var XATTR_CREATE = require('src/constants').XATTR_CREATE; var XATTR_REPLACE = require('src/constants').XATTR_REPLACE; - var NOMTIME = require('src/constants').NOMTIME; - var NOCTIME = require('src/constants').NOCTIME; + var FS_NOMTIME = require('src/constants').FS_NOMTIME; + var FS_NOCTIME = require('src/constants').FS_NOCTIME; var providers = require('src/providers/providers'); var adapters = require('src/adapters/adapters'); @@ -138,10 +138,10 @@ define(function(require) { function update_node_times(context, path, node, times, callback) { // Honour mount flags for how we update times var flags = context.flags; - if(_(flags).contains(NOCTIME)) { + if(_(flags).contains(FS_NOCTIME)) { delete times.ctime; } - if(_(flags).contains(NOMTIME)) { + if(_(flags).contains(FS_NOMTIME)) { delete times.mtime; }