TagSpaces is an offline, open source, document manager with tagging support
fixes - upload to S3 from/to subdirs tree only
stanimir7a28f0b551eb
diff --git a/app/components/DirectoryTreeView.tsx b/app/components/DirectoryTreeView.tsxindex ce5d09734..3cf59c6c4 100644--- a/app/components/DirectoryTreeView.tsx+++ b/app/components/DirectoryTreeView.tsx@@ -19,7 +19,7 @@import React, { useState, forwardRef, useImperativeHandle } from 'react';import Table from 'rc-table';import FolderIcon from '@material-ui/icons/FolderOpen';-import { Location } from '-/reducers/locations';+import { Location, locationType } from '-/reducers/locations';import DragItemTypes from '-/components/DragItemTypes';import AppConfig from '-/config';import PlatformIO from '-/services/platform-io';@@ -126,8 +126,20 @@ const DirectoryTreeView = forwardRef((props: Props, ref) => {};const onRowClick = subDir => {- loadSubDirectories(subDir, 1);- props.loadDirectoryContent(subDir.path);+ if (subDir.type === locationType.TYPE_CLOUD) {+ PlatformIO.enableObjectStoreSupport(subDir)+ .then(() => {+ loadSubDirectories(subDir, 1);+ props.loadDirectoryContent(subDir.path);+ })+ .catch(error => {+ console.log('enableObjectStoreSupport', error);+ });+ } else if (subDir.type === locationType.TYPE_LOCAL) {+ PlatformIO.disableObjectStoreSupport();+ loadSubDirectories(subDir, 1);+ props.loadDirectoryContent(subDir.path);+ }};const columns = [@@ -143,8 +155,13 @@ const DirectoryTreeView = forwardRef((props: Props, ref) => {const loadSubDirectories = (location: Location, deepLevel: number) => {const subFolder = {+ ...(location.accessKeyId && { accessKeyId: location.accessKeyId }),+ ...(location.bucketName && { bucketName: location.bucketName }),+ ...(location.region && { region: location.region }),+ ...(location.secretAccessKey && { secretAccessKey: location.secretAccessKey }),uuid: location.uuid,name: location.name,+ type: location.type,path: location.path || location.paths[0]};getDirectoriesTree(subFolder, deepLevel)@@ -180,8 +197,13 @@ const DirectoryTreeView = forwardRef((props: Props, ref) => {};type SubFolder = {+ accessKeyId?: string;+ bucketName?: string;+ region?: string;+ secretAccessKey?: string;uuid: string;name: string;+ type: string;path: string;children?: Array<SubFolder>;};@@ -203,7 +225,20 @@ const DirectoryTreeView = forwardRef((props: Props, ref) => {// const enhancedEntry = enhanceEntry(entry);if (!entry.isFile) {// eslint-disable-next-line no-param-reassign+ if (subFolder.accessKeyId) {+ entry.accessKeyId = subFolder.accessKeyId;+ }+ if (subFolder.bucketName) {+ entry.bucketName = subFolder.bucketName;+ }+ if (subFolder.region) {+ entry.region = subFolder.region;+ }+ if (subFolder.secretAccessKey) {+ entry.secretAccessKey = subFolder.secretAccessKey;+ }entry.uuid = subFolder.uuid;+ entry.type = subFolder.type;directoryContent.push(entry);}return true;diff --git a/app/components/LocationManager.tsx b/app/components/LocationManager.tsxindex f3d66817a..2014f98c0 100644--- a/app/components/LocationManager.tsx+++ b/app/components/LocationManager.tsx@@ -462,18 +462,18 @@ class LocationManager extends React.Component<Props, State> {} else {targetPath = item.children[1].props.record.path;} */- if (monitor && targetPath !== undefined) {+ if (monitor && targetPath !== undefined && targetLocation !== undefined) {// TODO handle monitor -> isOver and change folder iconconsole.log('Dropped files: ' + path);- if (targetLocation && targetLocation.type === locationType.TYPE_CLOUD) {+ if (targetLocation.type === locationType.TYPE_CLOUD) {PlatformIO.enableObjectStoreSupport(targetLocation).then(() => {this.props.uploadFiles(arrPath, targetPath);return true;}).catch(error => {console.log('enableObjectStoreSupport', error);});- } else {- // if (targetLocationType === locationType.TYPE_LOCAL) {+ } else if (targetLocation.type === locationType.TYPE_LOCAL) {+ PlatformIO.disableObjectStoreSupport();this.props.moveFiles(arrPath, targetPath);}this.props.setSelectedEntries([]);diff --git a/app/services/platform-io.ts b/app/services/platform-io.tsindex 7d9e2a592..9781ca874 100644--- a/app/services/platform-io.ts+++ b/app/services/platform-io.ts@@ -28,16 +28,20 @@ export default class PlatformIO {static enableObjectStoreSupport = (objectStoreConfig: Object): Promise<any> =>new Promise((resolve, reject) => {if (Pro && Pro.ObjectStoreIO) {- objectStoreAPI = new Pro.ObjectStoreIO();- objectStoreAPI- .configure(objectStoreConfig)- .then(() => {- resolve();- return true;- })- .catch(e => {- reject(e);- });+ if (objectStoreAPI !== undefined) { // TODO rethink this for the many same location types... && objectStoreAPI.accessKeyId === objectStoreConfig.accessKeyId) {+ resolve();+ } else {+ objectStoreAPI = new Pro.ObjectStoreIO();+ objectStoreAPI+ .configure(objectStoreConfig)+ .then(() => {+ resolve();+ return true;+ })+ .catch(e => {+ reject(e);+ });+ }} else {reject('ObjectStore support available in the PRO version');}