You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.3 KiB
43 lines
1.3 KiB
import {ErrorWithContext} from '../../error/ErrorWithContext'
|
|
import {Filesystem} from './Filesystem'
|
|
import {Awaitable} from '../types'
|
|
import {Writable} from 'stream'
|
|
|
|
/**
|
|
* Error thrown when attempting to perform an operation on a filesystem that doesn't support it.
|
|
*/
|
|
export class FilesystemOperationNotSupported extends ErrorWithContext {
|
|
constructor(fs: Filesystem, operation: string, context: any = {}) {
|
|
super(`The filesystem ${fs.constructor.name} does not support the ${operation} operation.`, context)
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Abstract base class for filesystems that are read-only (e.g. HTTP/S).
|
|
*/
|
|
export abstract class ReadOnlyFilesystem extends Filesystem {
|
|
putLocalFile(): Awaitable<void> {
|
|
throw new FilesystemOperationNotSupported(this, 'putLocalFile')
|
|
}
|
|
|
|
putStoreFileAsStream(): Awaitable<Writable> {
|
|
throw new FilesystemOperationNotSupported(this, 'putStoreFileAsStream')
|
|
}
|
|
|
|
touch(): Awaitable<void> {
|
|
throw new FilesystemOperationNotSupported(this, 'touch')
|
|
}
|
|
|
|
remove(): Awaitable<void> {
|
|
throw new FilesystemOperationNotSupported(this, 'remove')
|
|
}
|
|
|
|
mkdir(): Awaitable<void> {
|
|
throw new FilesystemOperationNotSupported(this, 'mkdir')
|
|
}
|
|
|
|
setMetadata(): Awaitable<void> {
|
|
throw new FilesystemOperationNotSupported(this, 'setMetadata')
|
|
}
|
|
}
|