Path: blob/master/src/packages/frontend/client/file.ts
1503 views
/*1* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.2* License: MS-RSL – see LICENSE.md for details3*/45import { redux } from "../app-framework";6import { required, defaults } from "@cocalc/util/misc";78export class FileClient {9constructor() {}1011// Returns true if the given file in the given project is currently12// marked as deleted.13public is_deleted(path: string, project_id: string): boolean {14return !!redux15.getProjectStore(project_id)16?.get("recentlyDeletedPaths")17?.get(path);18}1920public set_deleted(_filename, _project_id): void {21throw Error("set_deleted doesn't make sense for the frontend");22}2324// Mark the given file with the given action.25public async mark_file(opts: {26project_id: string;27path: string;28action: string;29ttl?: number;30}): Promise<void> {31opts = defaults(opts, {32project_id: required,33path: required,34action: required,35ttl: 120,36});37await redux38.getActions("file_use")39?.mark_file(opts.project_id, opts.path, opts.action, opts.ttl);40}41}424344