UNPKG

@solid/community-server

Version:

Community Solid Server: an open and modular implementation of the Solid specifications

25 lines (24 loc) 1.5 kB
import type { Readable } from 'node:stream'; import type { RepresentationMetadata } from '../../http/representation/RepresentationMetadata'; import type { ResourceIdentifier } from '../../http/representation/ResourceIdentifier'; import type { Guarded } from '../../util/GuardedStream'; import type { FileIdentifierMapper } from '../mapping/FileIdentifierMapper'; import type { AtomicDataAccessor } from './AtomicDataAccessor'; import { FileDataAccessor } from './FileDataAccessor'; /** * AtomicDataAccessor that uses the file system to store documents as files and containers as folders. * Data will first be written to a temporary location and only if no errors occur * will the data be written to the desired location. */ export declare class AtomicFileDataAccessor extends FileDataAccessor implements AtomicDataAccessor { private readonly tempFilePath; constructor(resourceMapper: FileIdentifierMapper, rootFilePath: string, tempFilePath: string); /** * Writes the given data as a file (and potential metadata as additional file). * Data will first be written to a temporary file and if no errors occur only then the * file will be moved to desired destination. * If the stream errors it is made sure the temporary file will be deleted. * The metadata file will only be written if the data was written successfully. */ writeDocument(identifier: ResourceIdentifier, data: Guarded<Readable>, metadata: RepresentationMetadata): Promise<void>; }