Skip to content

Commit

Permalink
fix list dropbox
Browse files Browse the repository at this point in the history
  • Loading branch information
antelle committed Apr 3, 2016
1 parent 4891dbf commit 341b963
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
12 changes: 7 additions & 5 deletions app/scripts/storage/storage-dropbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
var StorageBase = require('./storage-base'),
DropboxLink = require('../comp/dropbox-link'),
Locale = require('../util/locale'),
UrlUtils = require('../util/url-util');
UrlUtil = require('../util/url-util');

var StorageDropbox = StorageBase.extend({
name: 'dropbox',
Expand All @@ -27,7 +27,7 @@ var StorageDropbox = StorageBase.extend({
_toFullPath: function(path) {
var rootFolder = this.appSettings.get('dropboxFolder');
if (rootFolder) {
path = UrlUtils.fixSlashes('/' + rootFolder + '/' + path);
path = UrlUtil.fixSlashes('/' + rootFolder + '/' + path);
}
return path;
},
Expand All @@ -41,7 +41,7 @@ var StorageDropbox = StorageBase.extend({
} else if (ix === 1) {
path = path.substr(rootFolder.length + 1);
}
path = UrlUtils.fixSlashes('/' + path);
path = UrlUtil.fixSlashes('/' + path);
}
return path;
},
Expand Down Expand Up @@ -197,7 +197,9 @@ var StorageDropbox = StorageBase.extend({
DropboxLink.list(that._toFullPath(''), function(err, files, dirStat, filesStat) {
if (err) { return callback(err); }
var fileList = filesStat
.filter(function(f) { return !f.isFolder && !f.isRemoved; })
.filter(function(f) {
return !f.isFolder && !f.isRemoved && UrlUtil.isKdbx(f.name);
})
.map(function(f) {
return {
name: f.name,
Expand All @@ -206,7 +208,7 @@ var StorageDropbox = StorageBase.extend({
};
});
var dir = dirStat.inAppFolder ? Locale.openAppFolder :
(UrlUtils.trimStartSlash(dirStat.path) || Locale.openRootFolder);
(UrlUtil.trimStartSlash(dirStat.path) || Locale.openRootFolder);
callback(null, fileList, dir);
});
});
Expand Down
5 changes: 3 additions & 2 deletions app/scripts/storage/storage-onedrive.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

var StorageBase = require('./storage-base');
var StorageBase = require('./storage-base'),
UrlUtil = require('../util/url-util');

var OneDriveClientId = {
Production: '000000004818ED3A',
Expand Down Expand Up @@ -157,7 +158,7 @@ var StorageOneDrive = StorageBase.extend({
}
that.logger.debug('Listed', that.logger.ts(ts));
var fileList = response.value
.filter(function(f) { return f.name && /\.kdbx$/i.test(f.name); })
.filter(function(f) { return f.name && UrlUtil.isKdbx(f.name); })
.map(function(f) {
return {
name: f.name,
Expand Down
5 changes: 5 additions & 0 deletions app/scripts/util/url-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ var UrlUtil = {
multiSlashRegex: /\/{2,}/g,
lastPartRegex: /[^\/]+$/,
trimStartSlashRegex: /^\\/,
kdbxEndRegex: /\.kdbx$/i,

getDataFileName: function(url) {
var ix = url.lastIndexOf('/');
Expand All @@ -14,6 +15,10 @@ var UrlUtil = {
return url;
},

isKdbx: function(url) {
return url && this.kdbxEndRegex.test(url);
},

fixSlashes: function(url) {
return url.replace(this.multiSlashRegex, '/');
},
Expand Down

0 comments on commit 341b963

Please sign in to comment.