| | |
| | | var provider = CLOUD_PROVIDERS[provider_name]; |
| | | if (provider === undefined) return false; |
| | | |
| | | var requiredMethods = ['listFiles', 'downloadFile', 'uploadFile', 'removeFile']; |
| | | var requiredMethods = ['allFiles', 'read', 'write', 'rm']; |
| | | return requiredMethods.every(function(method) { |
| | | return (method in provider); |
| | | }); |
| | |
| | | return callback(null, { type: 'local', entries: entries }); |
| | | }, |
| | | getRemoteSet: function(mount, callback) { |
| | | mount.opts.provider.listFiles(mount.opts.cloud, function(data) { |
| | | mount.opts.provider.allFiles(mount.opts.cloud, function(data) { |
| | | var entries = {}, |
| | | toAbsolute = function(p) { return PATH.join2(mount.mountpoint, p); }; |
| | | for(var k in data) { |
| | |
| | | }, |
| | | loadRemoteEntry: function(mount, pathinfo, callback) { |
| | | if (pathinfo.type == 'file') { |
| | | mount.opts.provider.downloadFile(mount.opts.cloud, pathinfo.url, |
| | | mount.opts.provider.read(mount.opts.cloud, pathinfo.url, |
| | | function(data) { |
| | | callback(null, { contents: data, timestamp: pathinfo.timestamp, mode: {{{ cDefine('S_IFREG') | 0777 }}} }); |
| | | }, |
| | |
| | | }, |
| | | storeRemoteEntry: function(mount, pathinfo, entry, callback) { |
| | | if (FS.isFile(entry.mode)) { |
| | | mount.opts.provider.uploadFile(mount.opts.cloud, pathinfo, entry.contents, function() { |
| | | mount.opts.provider.write(mount.opts.cloud, pathinfo, entry.contents, function() { |
| | | callback(null); |
| | | }, |
| | | function(e) { |