Sync-in · Sovereign platform for file storage, sharing, synchronization, and collaboration.
TypeScript cloud-alternativecollaborationcollaborative-editingdropboxfile-serverfile-sharingfile-storagefile-syncfull-text-searchhomelabnextcloudon-premiseopen-sourceprivacy-firstprivate-cloudrealtimesecureself-hostedstorage-serverwebdav
import { FILE_OPERATION } from '../constants/operations.js'
export enum FileTaskStatus {
PENDING,
SUCCESS,
ERROR,
CANCELLED,
QUEUED
}
export interface FileTaskProps {
progress?: number
size?: number
totalSize?: number
compressInDirectory?: boolean
directories?: number
files?: number
src?: { name: string; path: string }
}
export class FileTask {
id: string
type: FILE_OPERATION
cancellable: boolean
status!: FileTaskStatus
path: string
name: string
props: FileTaskProps = {}
result!: string
startedAt!: number
endedAt!: number
constructor(id: string, type: FILE_OPERATION, path: string, name: string, cancellable = false) {
this.id = id
this.type = type
this.cancellable = cancellable
this.path = path
this.name = name
if (
type === FILE_OPERATION.COPY ||
type === FILE_OPERATION.MOVE ||
type === FILE_OPERATION.DOWNLOAD ||
(type === FILE_OPERATION.DELETE && cancellable)
) {
this.props = { progress: 1 }
if (type === FILE_OPERATION.COPY || type === FILE_OPERATION.MOVE) {
// copy move operation
this.props.src = { name: name, path: path }
}
}
}
}