Use local buildFilePath
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
|
||||
import superagent from 'superagent';
|
||||
import { buildFilePath, sanitize } from 'pankow/utils';
|
||||
import { sanitize } from 'pankow/utils';
|
||||
|
||||
const BASE_URL = import.meta.env.BASE_URL || '/';
|
||||
|
||||
@@ -8,6 +8,13 @@ export function createDirectoryModel(origin, accessToken, api) {
|
||||
|
||||
return {
|
||||
name: 'DirectoryModel',
|
||||
buildFilePath(filePath, fileName) {
|
||||
// remove leading and trailing slashes
|
||||
while (filePath.startsWith('/')) filePath = filePath.slice(1);
|
||||
while (filePath.endsWith('/')) filePath = filePath.slice(0, -1);
|
||||
|
||||
return encodeURIComponent(`${filePath}${filePath ? '/' : ''}${fileName}`);
|
||||
},
|
||||
async listFiles(path) {
|
||||
let error, result;
|
||||
try {
|
||||
@@ -118,8 +125,8 @@ export function createDirectoryModel(origin, accessToken, api) {
|
||||
let targetPath = targetDir + '/' + files[f].name;
|
||||
while (!done) {
|
||||
try {
|
||||
if (action === 'cut') await this.rename(buildFilePath(files[f].folderPath, files[f].name), targetPath);
|
||||
if (action === 'copy') await this.copy(buildFilePath(files[f].folderPath, files[f].name), targetPath);
|
||||
if (action === 'cut') await this.rename(this.buildFilePath(files[f].folderPath, files[f].name), targetPath);
|
||||
if (action === 'copy') await this.copy(this.buildFilePath(files[f].folderPath, files[f].name), targetPath);
|
||||
done = true;
|
||||
} catch (error) {
|
||||
if (error.status === 409) {
|
||||
|
||||
Reference in New Issue
Block a user