Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/src/packages/util/delete-files.ts
Views: 687
/*1* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.2* License: MS-RSL – see LICENSE.md for details3*/45import { path_split } from "./misc";6import { hidden_meta_file } from "@cocalc/util/misc";78// NOTE: there are also .term files in subframes with history that doesn't get9// deleted. That's an edge case.1011// This *includes* path.12export function deleted_file_variations(path: string): string[] {13let { head, tail } = path_split(path);14if (head != "") {15head = head + "/";16}17const variations: string[] = [path];18for (const ext of [19"sage-chat",20"sage-jupyter",21"sage-jupyter2",22"time-travel",23"sage-history",24"syncdb",25]) {26variations.push(head + hidden_meta_file(tail, ext));27}28return variations;29}3031// This does NOT include {src,dest}.32export function move_file_variations(33src: string,34dest: string,35): { src: string; dest: string }[] {36let { head, tail } = path_split(src);37if (head != "") {38head = head + "/";39}40const d = path_split(dest);41if (d.head != "") {42d.head = d.head + "/";43}44const variations: { src: string; dest: string }[] = [];45for (const ext of [46"sage-chat",47"sage-jupyter",48"sage-jupyter2",49"time-travel",50"sage-history",51]) {52variations.push({53src: head + "." + tail + "." + ext,54dest: d.head + "." + d.tail + "." + ext,55});56}57return variations;58}596061