mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-24 18:50:56 +08:00
chore: remove opendal dependency and related code from RemoteStorage service
This commit is contained in:
parent
9d2bd0221f
commit
4059855678
@ -94,7 +94,6 @@
|
||||
"markdown-it": "^14.1.0",
|
||||
"node-stream-zip": "^1.15.0",
|
||||
"officeparser": "^4.1.1",
|
||||
"opendal": "^0.47.11",
|
||||
"os-proxy-config": "^1.1.2",
|
||||
"proxy-agent": "^6.5.0",
|
||||
"rc-virtual-list": "^3.18.6",
|
||||
|
||||
@ -1,57 +1,57 @@
|
||||
import Logger from 'electron-log'
|
||||
import { Operator } from 'opendal'
|
||||
// import Logger from 'electron-log'
|
||||
// import { Operator } from 'opendal'
|
||||
|
||||
export default class RemoteStorage {
|
||||
public instance: Operator | undefined
|
||||
// export default class RemoteStorage {
|
||||
// public instance: Operator | undefined
|
||||
|
||||
/**
|
||||
*
|
||||
* @param scheme is the scheme for opendal services. Available value includes "azblob", "azdls", "cos", "gcs", "obs", "oss", "s3", "webdav", "webhdfs", "aliyun-drive", "alluxio", "azfile", "dropbox", "gdrive", "onedrive", "postgresql", "mysql", "redis", "swift", "mongodb", "alluxio", "b2", "seafile", "upyun", "koofr", "yandex-disk"
|
||||
* @param options is the options for given opendal services. Valid options depend on the scheme. Checkout https://docs.rs/opendal/latest/opendal/services/index.html for all valid options.
|
||||
*
|
||||
* For example, use minio as remote storage:
|
||||
*
|
||||
* ```typescript
|
||||
* const storage = new RemoteStorage('s3', {
|
||||
* endpoint: 'http://localhost:9000',
|
||||
* region: 'us-east-1',
|
||||
* bucket: 'testbucket',
|
||||
* access_key_id: 'user',
|
||||
* secret_access_key: 'password',
|
||||
* root: '/path/to/basepath',
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
constructor(scheme: string, options?: Record<string, string> | undefined | null) {
|
||||
this.instance = new Operator(scheme, options)
|
||||
// /**
|
||||
// *
|
||||
// * @param scheme is the scheme for opendal services. Available value includes "azblob", "azdls", "cos", "gcs", "obs", "oss", "s3", "webdav", "webhdfs", "aliyun-drive", "alluxio", "azfile", "dropbox", "gdrive", "onedrive", "postgresql", "mysql", "redis", "swift", "mongodb", "alluxio", "b2", "seafile", "upyun", "koofr", "yandex-disk"
|
||||
// * @param options is the options for given opendal services. Valid options depend on the scheme. Checkout https://docs.rs/opendal/latest/opendal/services/index.html for all valid options.
|
||||
// *
|
||||
// * For example, use minio as remote storage:
|
||||
// *
|
||||
// * ```typescript
|
||||
// * const storage = new RemoteStorage('s3', {
|
||||
// * endpoint: 'http://localhost:9000',
|
||||
// * region: 'us-east-1',
|
||||
// * bucket: 'testbucket',
|
||||
// * access_key_id: 'user',
|
||||
// * secret_access_key: 'password',
|
||||
// * root: '/path/to/basepath',
|
||||
// * })
|
||||
// * ```
|
||||
// */
|
||||
// constructor(scheme: string, options?: Record<string, string> | undefined | null) {
|
||||
// this.instance = new Operator(scheme, options)
|
||||
|
||||
this.putFileContents = this.putFileContents.bind(this)
|
||||
this.getFileContents = this.getFileContents.bind(this)
|
||||
}
|
||||
// this.putFileContents = this.putFileContents.bind(this)
|
||||
// this.getFileContents = this.getFileContents.bind(this)
|
||||
// }
|
||||
|
||||
public putFileContents = async (filename: string, data: string | Buffer) => {
|
||||
if (!this.instance) {
|
||||
return new Error('RemoteStorage client not initialized')
|
||||
}
|
||||
// public putFileContents = async (filename: string, data: string | Buffer) => {
|
||||
// if (!this.instance) {
|
||||
// return new Error('RemoteStorage client not initialized')
|
||||
// }
|
||||
|
||||
try {
|
||||
return await this.instance.write(filename, data)
|
||||
} catch (error) {
|
||||
Logger.error('[RemoteStorage] Error putting file contents:', error)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
// try {
|
||||
// return await this.instance.write(filename, data)
|
||||
// } catch (error) {
|
||||
// Logger.error('[RemoteStorage] Error putting file contents:', error)
|
||||
// throw error
|
||||
// }
|
||||
// }
|
||||
|
||||
public getFileContents = async (filename: string) => {
|
||||
if (!this.instance) {
|
||||
throw new Error('RemoteStorage client not initialized')
|
||||
}
|
||||
// public getFileContents = async (filename: string) => {
|
||||
// if (!this.instance) {
|
||||
// throw new Error('RemoteStorage client not initialized')
|
||||
// }
|
||||
|
||||
try {
|
||||
return await this.instance.read(filename)
|
||||
} catch (error) {
|
||||
Logger.error('[RemoteStorage] Error getting file contents:', error)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
}
|
||||
// try {
|
||||
// return await this.instance.read(filename)
|
||||
// } catch (error) {
|
||||
// Logger.error('[RemoteStorage] Error getting file contents:', error)
|
||||
// throw error
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
80
yarn.lock
80
yarn.lock
@ -2766,55 +2766,6 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@opendal/lib-darwin-arm64@npm:0.47.11":
|
||||
version: 0.47.11
|
||||
resolution: "@opendal/lib-darwin-arm64@npm:0.47.11"
|
||||
conditions: os=darwin & cpu=arm64
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@opendal/lib-darwin-x64@npm:0.47.11":
|
||||
version: 0.47.11
|
||||
resolution: "@opendal/lib-darwin-x64@npm:0.47.11"
|
||||
conditions: os=darwin & cpu=x64
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@opendal/lib-linux-arm64-gnu@npm:0.47.11":
|
||||
version: 0.47.11
|
||||
resolution: "@opendal/lib-linux-arm64-gnu@npm:0.47.11"
|
||||
conditions: os=linux & cpu=arm64 & libc=glibc
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@opendal/lib-linux-arm64-musl@npm:0.47.11":
|
||||
version: 0.47.11
|
||||
resolution: "@opendal/lib-linux-arm64-musl@npm:0.47.11"
|
||||
conditions: os=linux & cpu=arm64 & libc=glibc
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@opendal/lib-linux-x64-gnu@npm:0.47.11":
|
||||
version: 0.47.11
|
||||
resolution: "@opendal/lib-linux-x64-gnu@npm:0.47.11"
|
||||
conditions: os=linux & cpu=x64 & libc=glibc
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@opendal/lib-win32-arm64-msvc@npm:0.47.11":
|
||||
version: 0.47.11
|
||||
resolution: "@opendal/lib-win32-arm64-msvc@npm:0.47.11"
|
||||
conditions: os=win32 & cpu=arm64
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@opendal/lib-win32-x64-msvc@npm:0.47.11":
|
||||
version: 0.47.11
|
||||
resolution: "@opendal/lib-win32-x64-msvc@npm:0.47.11"
|
||||
conditions: os=win32 & cpu=x64
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@parcel/watcher-android-arm64@npm:2.5.1":
|
||||
version: 2.5.1
|
||||
resolution: "@parcel/watcher-android-arm64@npm:2.5.1"
|
||||
@ -4493,7 +4444,6 @@ __metadata:
|
||||
npx-scope-finder: "npm:^1.2.0"
|
||||
officeparser: "npm:^4.1.1"
|
||||
openai: "patch:openai@npm%3A4.96.0#~/.yarn/patches/openai-npm-4.96.0-0665b05cb9.patch"
|
||||
opendal: "npm:^0.47.11"
|
||||
os-proxy-config: "npm:^1.1.2"
|
||||
p-queue: "npm:^8.1.0"
|
||||
prettier: "npm:^3.5.3"
|
||||
@ -13030,36 +12980,6 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"opendal@npm:^0.47.11":
|
||||
version: 0.47.11
|
||||
resolution: "opendal@npm:0.47.11"
|
||||
dependencies:
|
||||
"@opendal/lib-darwin-arm64": "npm:0.47.11"
|
||||
"@opendal/lib-darwin-x64": "npm:0.47.11"
|
||||
"@opendal/lib-linux-arm64-gnu": "npm:0.47.11"
|
||||
"@opendal/lib-linux-arm64-musl": "npm:0.47.11"
|
||||
"@opendal/lib-linux-x64-gnu": "npm:0.47.11"
|
||||
"@opendal/lib-win32-arm64-msvc": "npm:0.47.11"
|
||||
"@opendal/lib-win32-x64-msvc": "npm:0.47.11"
|
||||
dependenciesMeta:
|
||||
"@opendal/lib-darwin-arm64":
|
||||
optional: true
|
||||
"@opendal/lib-darwin-x64":
|
||||
optional: true
|
||||
"@opendal/lib-linux-arm64-gnu":
|
||||
optional: true
|
||||
"@opendal/lib-linux-arm64-musl":
|
||||
optional: true
|
||||
"@opendal/lib-linux-x64-gnu":
|
||||
optional: true
|
||||
"@opendal/lib-win32-arm64-msvc":
|
||||
optional: true
|
||||
"@opendal/lib-win32-x64-msvc":
|
||||
optional: true
|
||||
checksum: 10c0/0783da2651bb27ac693ce38938d12b00124530fb965364517eef3de17b3ff898cdecf06260a79a7d70745d57c2ba952a753a4bab52e0831aa7232c3a69120225
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"option@npm:~0.2.1":
|
||||
version: 0.2.4
|
||||
resolution: "option@npm:0.2.4"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user