chore(fs): simplify sync/forget
- These methods are now optional - sync no longer returns anything
This commit is contained in:
parent
043b381733
commit
2c93b69144
@ -283,8 +283,8 @@ export default class RemoteHandlerAbstract {
|
||||
|
||||
// Asks the handler to sync the state of the effective remote with its'
|
||||
// metadata
|
||||
async sync(): Promise<mixed> {
|
||||
return this._sync()
|
||||
async sync(): Promise<void> {
|
||||
await this._sync()
|
||||
}
|
||||
|
||||
async test(): Promise<Object> {
|
||||
@ -340,9 +340,8 @@ export default class RemoteHandlerAbstract {
|
||||
throw new Error('Not implemented')
|
||||
}
|
||||
|
||||
async _forget(): Promise<void> {
|
||||
throw new Error('Not implemented')
|
||||
}
|
||||
// called to finalize the remote
|
||||
async _forget(): Promise<void> {}
|
||||
|
||||
async _getSize(file: File): Promise<number> {
|
||||
throw new Error('Not implemented')
|
||||
@ -404,9 +403,8 @@ export default class RemoteHandlerAbstract {
|
||||
return this._rmtree(dir)
|
||||
}
|
||||
|
||||
async _sync(): Promise<mixed> {
|
||||
throw new Error('Not implemented')
|
||||
}
|
||||
// called to initialize the remote
|
||||
async _sync(): Promise<void> {}
|
||||
|
||||
async _unlink(file: string): Promise<void> {
|
||||
throw new Error('Not implemented')
|
||||
|
@ -1,6 +1,5 @@
|
||||
import fs from 'fs-extra'
|
||||
import { dirname } from 'path'
|
||||
import { noop } from 'lodash'
|
||||
|
||||
import RemoteHandlerAbstract from './abstract'
|
||||
|
||||
@ -44,10 +43,6 @@ export default class LocalHandler extends RemoteHandlerAbstract {
|
||||
})
|
||||
}
|
||||
|
||||
async _forget() {
|
||||
return noop()
|
||||
}
|
||||
|
||||
async _getSize(file) {
|
||||
const stats = await fs.stat(
|
||||
this._getFilePath(typeof file === 'string' ? file : file.path)
|
||||
@ -100,11 +95,9 @@ export default class LocalHandler extends RemoteHandlerAbstract {
|
||||
}
|
||||
|
||||
async _sync() {
|
||||
const path = this._getRealPath()
|
||||
const path = this._getRealPath('/')
|
||||
await fs.ensureDir(path)
|
||||
await fs.access(path, fs.R_OK | fs.W_OK)
|
||||
|
||||
return this._remote
|
||||
}
|
||||
|
||||
async _unlink(file) {
|
||||
|
@ -4,8 +4,6 @@ import { finished } from 'readable-stream'
|
||||
|
||||
import RemoteHandlerAbstract from './abstract'
|
||||
|
||||
const noop = () => {}
|
||||
|
||||
// Normalize the error code for file not found.
|
||||
const wrapError = (error, code) => ({
|
||||
__proto__: error,
|
||||
@ -30,7 +28,6 @@ const normalizeError = (error, shouldBeDirectory) => {
|
||||
export default class SmbHandler extends RemoteHandlerAbstract {
|
||||
constructor(remote, opts) {
|
||||
super(remote, opts)
|
||||
this._forget = noop
|
||||
|
||||
const prefix = this._remote.path
|
||||
this._prefix = prefix !== '' ? prefix + '\\' : prefix
|
||||
@ -228,8 +225,6 @@ export default class SmbHandler extends RemoteHandlerAbstract {
|
||||
async _sync() {
|
||||
// Check access (smb2 does not expose connect in public so far...)
|
||||
await this.list('.')
|
||||
|
||||
return this._remote
|
||||
}
|
||||
|
||||
async _unlink(file) {
|
||||
|
Loading…
Reference in New Issue
Block a user