Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import path from 'path';
import { combineReducers } from 'redux';
import webdavFs from 'webdav-fs';
import anyFs from 'any-fs';
const wfs = webdavFs('', 'buttercup', '');
const afs = anyFs(wfs);
// Constants ->
const SET_CURRENT_PATH = 'buttercup/manager/SET_CURRENT_PATH';
const SET_CONTENTS = 'buttercup/manager/SET_CONTENTS';
const LOADING_STARTED = 'buttercup/manager/LOADING_STARTED';
const LOADING_FINISHED = 'buttercup/manager/LOADING_FINISHED';
const ADD_DIRECTORY = 'buttercup/manager/ADD_DIRECTORY';
const SELECT_FILE_INDEX = 'buttercup/manager/SELECT_FILE_INDEX';
// Reducers ->
function currentPath(state = '', action) {
switch (action.type) {
case SET_CURRENT_PATH:
return action.payload;
default:
export function getFsInstance(type, settings) {
switch (type) {
case 'dropbox':
return anyFs(
dropboxFs({
apiKey: settings.token
})
);
case 'webdav':
return anyFs(
webdavFs(settings.endpoint, settings.username, settings.password)
);
default:
return null;
}
}
createFS() {
if (this.state.owncloudAddress.trim().length <= 0) {
return null;
}
let wfs;
const owncloudAddress = url.resolve(this.state.owncloudAddress, "remote.php/webdav/");
if (this.state.owncloudUsername && this.state.owncloudUsername.trim().length > 0) {
if (this.state.owncloudPassword.trim().length <= 0) {
return null;
}
wfs = createWebDAVFS(
owncloudAddress,
this.state.owncloudUsername,
this.state.owncloudPassword
);
return anyFs(wfs);
}
return null;
}
createFS() {
if (this.state.webdav_address.trim().length <= 0) {
return null;
}
let wfs;
if (this.state.webdav_username && this.state.webdav_username.trim().length > 0) {
if (this.state.webdav_password.trim().length <= 0) {
return null;
}
wfs = createWebDAVFS(
this.state.webdav_address,
this.state.webdav_username,
this.state.webdav_password
);
return anyFs(wfs);
}
return null;
}