@teambit/clear-cache 0.0.619 → 0.0.621
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.workspace_clear-cache@0.0.
|
|
2
|
-
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.workspace_clear-cache@0.0.
|
|
1
|
+
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.workspace_clear-cache@0.0.621/dist/clear-cache.composition.js';
|
|
2
|
+
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.workspace_clear-cache@0.0.621/dist/clear-cache.docs.mdx';
|
|
3
3
|
|
|
4
4
|
export const compositions = [compositions_0];
|
|
5
5
|
export const overview = [overview_0];
|
|
@@ -531,7 +531,8 @@ ${list}`);
|
|
|
531
531
|
if (!version) return;
|
|
532
532
|
kept.add(hash);
|
|
533
533
|
version.refsWithOptions(false, true).forEach(ref => kept.add(ref.toString()));
|
|
534
|
-
|
|
534
|
+
const flattenedDependencies = await version.loadFlattenedDependencies(repo);
|
|
535
|
+
flattenedDependencies.forEach(dependency => dependencies.add(dependency.toString()));
|
|
535
536
|
// an env or aspect the version was built with. versions written by older bits record
|
|
536
537
|
// these only here, so taking `flattenedDependencies` at its word would miss them.
|
|
537
538
|
version.extensions.extensionsBitIds.forEach(extension => dependencies.add(extension.toString()));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_fsExtra","data","_interopRequireDefault","require","_path","_glob","_lodash","_bitError","_componentId","_legacy","_harmonyModules","_toolboxPromise","_objects","_component","_legacy2","e","__esModule","default","STRAY_TEMP_FILE","STRAY_TEMP_FILE_MIN_AGE_MS","RECENT_WRITE_MARGIN_MS","STASH_DIR","collectGarbageInWorkspace","scope","workspaceIds","opts","dryRun","verbose","keepVersions","backup","repo","objects","concurrency","concurrentIOLimit","startedAt","Date","now","backupDirSize","trashSize","stashSize","Promise","all","getDirSize","path","join","DELETED_OBJECTS_DIR","getTrashDir","retainedDirsSize","logger","debug","name","allObjects","unreadable","listObjectsWithType","length","list","map","ref","objectPath","BitError","versionHashes","Set","refsByType","Map","recentlyWrittenVersions","settledBefore","totalSize","forEach","type","size","mtimeMs","Version","add","toString","push","existing","get","set","entries","t","r","rootVersions","addRoot","hash","has","addNewRoot","componentKey","component","toComponentId","toStringWithoutVersion","loadObjectsOfType","refs","pMapPool","load","compact","components","ModelComponent","liveLanes","Lane","lanes","getTrashedLanes","componentsById","getComponent","id","getModelComponentIfExist","changeVersion","undefined","detachedHeads","getHead","getAllHeads","head","Object","values","orphanedVersions","checkedOutHeads","workspaceComponents","version","checkedOut","hasVersion","getRef","workspaceComponentIds","laneHeads","unattachedLaneHeads","lane","toComponentIdsIncludeUpdateDependents","Ref","from","readmeComponent","laneHistories","LaneHistory","laneHistory","getHistory","item","ids","deleted","updateDependents","idStr","ComponentID","fromString","remoteRefsPerComponent","remoteLanes","getAllRefsPerComponent","remoteRefs","bareRoots","stagedSnaps","getAll","getStashedHashes","keepAncestryOf","unmergedRoots","unmergedComponents","getComponents","flatMap","unmerged","unrelated","headOnCurrentLane","unrelatedHead","stopAtRemote","keepHistoryOf","filter","limit","keep","keepReferencedVersions","versionRefsToDelete","sourceRefsToDelete","deletedByType","deletedSize","recentlyWritten","Source","count","console","strayFiles","removeStrayTempFiles","getPath","deletedObjects","remove","moveObjectsToDir","deleteObjectsFromFS","backupDir","totalObjects","keptVersions","strayFilesSize","hashes","seen","queue","pop","parents","parent","startingPoints","Infinity","remoteHeads","some","remoteHead","isEqual","versionsInfo","getAllVersionsInfo","modelComponent","startFrom","stopAt","throws","slice","versionInfo","kept","frontier","dependencies","added","refsWithOptions","flattenedDependencies","dependency","extensions","extensionsBitIds","extension","scopePath","stashDir","fs","pathExists","files","readdir","file","endsWith","hashesPerFile","filePath","unusable","reason","content","readJson","err","message","compsData","stashCompsData","Array","isArray","compData","index","flat","restoreDeletedObjects","overwrite","deletedObjectsDir","leftovers","glob","cwd","staged","claim","dir","claimed","process","pid","move","stagingDir","restoreFromDir","dirPath","nodir","dot","sizes","stat","reduce","sum","listTrash","getFromTrash","object","objectsPath","matches","candidates","match","test","basename","staleBefore","strays","candidate","isFile"],"sources":["workspace-garbage-collector.ts"],"sourcesContent":["import fs from 'fs-extra';\nimport path from 'path';\nimport { glob } from 'glob';\nimport { compact } from 'lodash';\nimport { BitError } from '@teambit/bit-error';\nimport { ComponentID } from '@teambit/component-id';\nimport { logger } from '@teambit/legacy.logger';\nimport { concurrentIOLimit } from '@teambit/harmony.modules.concurrency';\nimport { pMapPool } from '@teambit/toolbox.promise.map-pool';\nimport type { Repository } from '@teambit/objects';\nimport { Lane, LaneHistory, ModelComponent, Ref, Source, Version } from '@teambit/objects';\nimport { getAllVersionsInfo } from '@teambit/component.snap-distance';\nimport type { Scope } from '@teambit/legacy.scope';\nimport { DELETED_OBJECTS_DIR } from '@teambit/legacy.scope';\n\n/**\n * a leftover of an interrupted atomic write - `<38-hex>.<pid-ish digits>` next to the object it was\n * about to become. `Repository.listRefs` skips them (they're not valid object paths), so nothing\n * ever cleans them up.\n */\nconst STRAY_TEMP_FILE = /^[0-9a-f]{38}\\.\\d+$/;\n\n/**\n * how long a file of that shape has to have been sitting there before it counts as abandoned\n * rather than as a write someone is in the middle of.\n */\nconst STRAY_TEMP_FILE_MIN_AGE_MS = 60 * 60 * 1000;\n\n/**\n * how recently an object must have been written for this run to decline to judge it. covers the\n * gap between another process writing a `Version` and pointing a `ModelComponent` at it.\n */\nconst RECENT_WRITE_MARGIN_MS = 5 * 60 * 1000;\n\n/**\n * `bit stash` writes a `Version` object into the local scope and records only its hash in a file\n * here. deliberately nothing else refers to it - not the component, not a lane, not `.bitmap`.\n */\nconst STASH_DIR = 'stash';\n\nexport type WorkspaceGcOptions = {\n dryRun?: boolean;\n verbose?: boolean;\n /**\n * in addition to the version each component is checked out at, keep the last N versions of every\n * workspace component, so their recent history (`bit log`, `bit blame`, `bit diff`) stays local.\n */\n keepVersions?: number;\n /**\n * move the objects into a `deleted-objects` directory instead of deleting them, so that\n * `--restore` can bring them back. note that this doesn't free any disk space.\n */\n backup?: boolean;\n};\n\ntype StrayTempFiles = { count: number; size: number };\n\n/** a head to walk back from, along with the component it belongs to */\ntype ComponentHead = { component: ModelComponent; head?: Ref };\n\nexport type GcResult = {\n dryRun: boolean;\n /** what --backup asked for. `backupDir` only says where objects went, so a dry run has none */\n backup: boolean;\n backupDir?: string;\n totalObjects: number;\n /** everything the scope holds on disk - live objects, stray temp files, trash, stash, backup */\n totalSize: number;\n deletedObjects: number;\n /** the objects only. with --backup these bytes move to the backup directory rather than leave */\n deletedSize: number;\n deletedByType: { [type: string]: { count: number; size: number } };\n keptVersions: number;\n strayFiles: number;\n /** freed regardless of --backup, which applies to objects only */\n strayFilesSize: number;\n /** what earlier --backup runs left behind, measured before this one moves anything into it */\n backupDirSize: number;\n /** the trash and the stash, which are part of the scope's weight but never freed by gc */\n retainedDirsSize: number;\n};\n\n/**\n * remove objects a workspace doesn't need from its local scope.\n *\n * a workspace accumulates objects indefinitely: every `bit import` brings the new head of each\n * component along with the source files of that version, and nothing ever removes the versions\n * that were superseded. after a while the bulk of the scope is file contents of versions no one\n * will ever ask for again.\n *\n * unlike the garbage collector that runs on a bare (remote) scope, this one is not bound to keep\n * history: a workspace scope is a cache, not the source of truth. anything deleted here can be\n * re-fetched from the remote, and `sources.get()` already checks whether the specific `Version`\n * object exists locally before deciding it has nothing to fetch.\n *\n * that last point is why versions are pruned whole - the `Version` object together with the\n * `Source` objects it points to. keeping a `Version` whose file contents were deleted would look\n * to the importer exactly like a version that's fully present, so it would skip the fetch and only\n * fail later, when something tries to read the files.\n *\n * the scope itself knows nothing about workspaces. it's given the ids that are in use and the\n * hashes that must survive; deciding what those are is this aspect's job.\n */\nexport async function collectGarbageInWorkspace(\n scope: Scope,\n workspaceIds: ComponentID[],\n opts: WorkspaceGcOptions = {}\n): Promise<GcResult> {\n const { dryRun = false, verbose = false, keepVersions = 0, backup = false } = opts;\n const repo = scope.objects;\n const concurrency = concurrentIOLimit();\n // taken before anything is read, so it's never later than the inventory it will be compared to\n const startedAt = Date.now();\n\n // measured before anything moves into it, so this run's own objects are not counted twice - they\n // are still in `objects/` when the inventory below is taken. the trash and the stash are here for\n // the same reason the backup directory is: they sit inside the scope and weigh what they weigh,\n // and a report that leaves them out has the scope shrinking while the disk does not. gc frees\n // none of the three, so they stay on both sides of the before/after.\n const [backupDirSize, trashSize, stashSize] = await Promise.all([\n getDirSize(path.join(scope.path, DELETED_OBJECTS_DIR)),\n getDirSize(repo.getTrashDir()),\n getDirSize(path.join(scope.path, STASH_DIR)),\n ]);\n const retainedDirsSize = trashSize + stashSize;\n\n logger.debug(`gc, classifying the objects of ${scope.name}`);\n const { objects: allObjects, unreadable } = await repo.listObjectsWithType();\n\n // an object we couldn't classify is an object we can't reason about. if it happens to be a live\n // `Version`, we'd never learn which `Source` objects it points at, and would delete them while\n // leaving the version in place - the one state this collector exists to avoid. so rather than\n // deleting from a partial inventory, refuse to delete at all.\n if (unreadable.length) {\n const list = unreadable.map((ref) => ` ${repo.objectPath(ref)}`).join('\\n');\n throw new BitError(`unable to read ${unreadable.length} object(s) in the scope, so it is not safe to run gc.\nthese objects are most likely corrupted. bit can fetch them again from the remote, so it is safe to\ndelete them and run gc again:\n${list}`);\n }\n\n const versionHashes = new Set<string>();\n const refsByType = new Map<string, Ref[]>();\n const recentlyWrittenVersions: string[] = [];\n const settledBefore = startedAt - RECENT_WRITE_MARGIN_MS;\n let totalSize = 0;\n allObjects.forEach(({ ref, type, size, mtimeMs }) => {\n totalSize += size;\n if (type === Version.name) {\n versionHashes.add(ref.toString());\n if (mtimeMs > settledBefore) recentlyWrittenVersions.push(ref.toString());\n }\n const existing = refsByType.get(type);\n if (existing) existing.push(ref);\n else refsByType.set(type, [ref]);\n });\n logger.debug(\n `gc, ${allObjects.length} objects: ${[...refsByType.entries()].map(([t, r]) => `${t}:${r.length}`).join(', ')}`\n );\n\n /**\n * the versions to keep in full. a hash is only accepted if a `Version` object with that hash is\n * actually here - a head pointing at something we never fetched is not our problem to keep.\n */\n const rootVersions = new Set<string>();\n const addRoot = (ref?: Ref | string | null) => {\n if (!ref) return;\n const hash = ref.toString();\n if (versionHashes.has(hash)) rootVersions.add(hash);\n };\n /** `addRoot`, reporting whether the hash is a root only as of this call - i.e. one still to walk */\n const addNewRoot = (hash: string): boolean => {\n if (rootVersions.has(hash)) return false;\n addRoot(hash);\n return rootVersions.has(hash);\n };\n const componentKey = (component: ModelComponent) => component.toComponentId().toStringWithoutVersion();\n\n const loadObjectsOfType = async <T>(type: string): Promise<T[]> => {\n const refs = refsByType.get(type) || [];\n const objects = await pMapPool(refs, (ref) => ref.load(repo), { concurrency });\n return compact(objects) as T[];\n };\n\n const components = await loadObjectsOfType<ModelComponent>(ModelComponent.name);\n const liveLanes = await loadObjectsOfType<Lane>(Lane.name);\n // `bit lane remove` moves the `Lane` object to the trash rather than deleting it, so that it can\n // be brought back. a lane sitting there still names the snaps it held, and if those are gone the\n // lane comes back empty-handed. the collector for bare scopes has always counted them; this one\n // has the same reason to.\n const lanes = [...liveLanes, ...(await getTrashedLanes(repo))];\n const componentsById = new Map(components.map((component) => [componentKey(component), component]));\n // every component object has just been loaded, so going back through the scope is only for the\n // one it can't be matched to by id - a symlink, say.\n const getComponent = async (id: ComponentID): Promise<ModelComponent | undefined> =>\n componentsById.get(id.toStringWithoutVersion()) || scope.getModelComponentIfExist(id.changeVersion(undefined));\n\n // the head of every component. `bit log`, `bit status` and the diverge calculation all start\n // there, and it's what `VersionHistory` is repaired from when it turns out to be incomplete.\n const detachedHeads: ComponentHead[] = [];\n components.forEach((component) => {\n addRoot(component.getHead());\n component.detachedHeads.getAllHeads().forEach((head) => {\n addRoot(head);\n detachedHeads.push({ component, head });\n });\n // an orphaned tag reached this scope through some other remote's cache rather than through the\n // component's origin, which is the whole reason bit holds on to it locally. re-fetching it is\n // not something we can count on, so it is treated like anything else that exists only here.\n Object.values(component.orphanedVersions).forEach(addRoot);\n });\n\n // the version each workspace component is checked out at - `bit status` diffs the working\n // directory against it, so it's read on virtually every command. kept for `--keep-versions` too.\n const checkedOutHeads: ComponentHead[] = [];\n const workspaceComponents = compact(\n await pMapPool(\n workspaceIds,\n async (id) => {\n // a snap id is already the hash, so it stands on its own. rooting it before the lookup\n // means a component object that is missing or unreadable can't take the version the\n // workspace is sitting on down with it. a tag resolves through the component below.\n addRoot(id.version);\n const component = await getComponent(id);\n if (!component) return null;\n // the head is the fallback for a version the component can't resolve - a lane snap, say,\n // which `addRoot(id.version)` above has already taken care of on its own.\n const checkedOut =\n (id.hasVersion() ? component.getRef(id.version as string) : undefined) || component.getHead();\n addRoot(checkedOut);\n if (checkedOut) checkedOutHeads.push({ component, head: checkedOut });\n return component;\n },\n { concurrency }\n )\n );\n const workspaceComponentIds = new Set(workspaceComponents.map(componentKey));\n\n // heads of every component on every local lane, `updateDependents` included.\n const laneHeads: ComponentHead[] = [];\n /** lane heads whose component object isn't here, so `keepHistoryOf` can't walk them */\n const unattachedLaneHeads: string[] = [];\n lanes.forEach((lane) => {\n lane.toComponentIdsIncludeUpdateDependents().forEach((id) => {\n addRoot(id.version);\n if (!id.version) return;\n const component = componentsById.get(id.toStringWithoutVersion());\n // without a component the tip would be rooted on its own and its chain left to the deletion\n // pass, which is the wrong half to keep for a lane that was never exported.\n if (component) laneHeads.push({ component, head: Ref.from(id.version) });\n else unattachedLaneHeads.push(id.version);\n });\n // the lane's readme is pointed at separately and needn't be among the components above\n addRoot(lane.readmeComponent?.head);\n });\n\n // `bit lane history` can check out or revert to any entry it recorded, and it hands checkout the\n // exact versions written there. a version that has since left the lane is reachable from nothing\n // else, and on a lane that was never exported it is here and nowhere else.\n const laneHistories = await loadObjectsOfType<LaneHistory>(LaneHistory.name);\n laneHistories.forEach((laneHistory) => {\n Object.values(laneHistory.getHistory()).forEach((item) => {\n const ids = [...item.components, ...(item.deleted || []), ...(item.updateDependents || [])];\n ids.forEach((idStr) => addRoot(ComponentID.fromString(idStr).version));\n });\n });\n\n // heads we track for remotes. deleting one would break the diverge calculation, which can no\n // longer reach it and has no way to tell that it's gone rather than never-fetched.\n const remoteRefsPerComponent = await repo.remoteLanes.getAllRefsPerComponent();\n const remoteRefs = new Set<string>();\n remoteRefsPerComponent.forEach((refs) =>\n refs.forEach((ref) => {\n addRoot(ref);\n remoteRefs.add(ref.toString());\n })\n );\n\n // snaps that were created here and never exported. nothing can bring these back, and for these\n // the tip alone is not enough: export sends the whole chain up to what the remote already has,\n // and `bit stash load` reads the parent of the stashed snap as the base of its three-way merge.\n // they arrive as bare hashes with no component to resolve them against, so the ancestry is\n // walked directly rather than through `keepHistoryOf`.\n const bareRoots = [...scope.stagedSnaps.getAll(), ...(await getStashedHashes(scope.path))];\n await keepAncestryOf([...bareRoots, ...unattachedLaneHeads]);\n\n // a merge that hasn't been resolved yet. the incoming side may have been imported from one scope\n // in order to be exported onward to another, and it's the target's head that bounds what export\n // has to send - not the head of the scope it came from. rather than work out which remote is\n // which, the chain is kept whole: an unresolved merge is a passing state on a handful of\n // components, so keeping more of it than strictly needed costs little and guessing wrong here\n // breaks the merge.\n const unmergedRoots = compact(\n repo.unmergedComponents.getComponents().flatMap((unmerged) => [\n unmerged.head,\n // `unrelated` is a boolean on entries written by older versions, which carry no extra hashes.\n ...(typeof unmerged.unrelated === 'object'\n ? [unmerged.unrelated.headOnCurrentLane, unmerged.unrelated.unrelatedHead]\n : []),\n ])\n ).map((hash) => hash.toString());\n await keepAncestryOf(unmergedRoots, { stopAtRemote: false });\n\n // snaps that were created here and not exported yet must be kept in full, not only their tip -\n // export sends the entire chain up to what the remote already has. `staged-snaps` normally\n // records them, but it's written per-snap and older workspaces predate it, so the chains are\n // walked rather than trusted. a detached head is a tip like any other: its unexported parents are\n // reachable from nowhere else.\n //\n // `getHeadRegardlessOfLane` is of no use here or below: `laneHeadLocal` is populated at runtime\n // by whoever checked the lane out, and these components were loaded straight from the objects.\n await keepHistoryOf(\n [...components.map((component) => ({ component, head: component.getHead() })), ...laneHeads, ...detachedHeads],\n { stopAtRemote: true }\n );\n\n /**\n * a version written around the time this run started is one nobody may be pointing at yet: an\n * import or a snap writes the `Version` and its `Source` objects first and updates the\n * `ModelComponent` after, so a run that reads the components in between sees garbage that isn't.\n *\n * it goes in as a root rather than being skipped when candidates are picked, because that is\n * what carries its `Source` objects with it. sparing the version alone would leave exactly the\n * state this collector exists to avoid - a version that looks complete with its files gone, so\n * the importer never fetches and something fails later trying to read them.\n *\n * this narrows the window rather than closing it. only a scope-wide lock held across every\n * object write would close it, and there is none today. the cost of being wrong is one more run.\n */\n recentlyWrittenVersions.forEach(addRoot);\n\n // `--keep-versions N`. counted back from where the workspace actually sits, which is not always\n // the head: the last N versions of a component checked out behind its head are not the head's.\n // the head is kept regardless, so starting there as well would just double what N means. on a\n // lane the recent history asked for is the lane's, hence its heads too.\n if (keepVersions > 0) {\n await keepHistoryOf(\n [...checkedOutHeads, ...laneHeads.filter(({ component }) => workspaceComponentIds.has(componentKey(component)))],\n { limit: keepVersions }\n );\n }\n\n logger.debug(`gc, ${rootVersions.size} root versions before resolving dependencies`);\n const keep = await keepReferencedVersions();\n logger.debug(`gc, ${rootVersions.size} root versions in total`);\n\n // everything that is neither a Version nor a Source is structural - components, lanes, version\n // histories, scope metadata. together they're a fraction of a percent of the scope and they're\n // what makes the rest of it navigable, so they're never candidates for deletion.\n // split by type so the removal can take the versions first - see below\n const versionRefsToDelete: Ref[] = [];\n const sourceRefsToDelete: Ref[] = [];\n const deletedByType: { [type: string]: { count: number; size: number } } = {};\n let deletedSize = 0;\n /**\n * the other half of the recent-write margin. a fresh `Version` was kept as a root above, which\n * brought its files with it; this catches a `Source` written just before the `Version` that will\n * refer to it, which no root can speak for yet.\n */\n let recentlyWritten = 0;\n allObjects.forEach(({ ref, type, size, mtimeMs }) => {\n if (type !== Version.name && type !== Source.name) return;\n if (keep.has(ref.toString())) return;\n if (mtimeMs > settledBefore) {\n recentlyWritten += 1;\n return;\n }\n if (type === Version.name) versionRefsToDelete.push(ref);\n else sourceRefsToDelete.push(ref);\n deletedSize += size;\n if (!deletedByType[type]) deletedByType[type] = { count: 0, size: 0 };\n deletedByType[type].count += 1;\n deletedByType[type].size += size;\n if (verbose) logger.console(`gc, deleting ${type} ${ref.toString()}`);\n });\n if (recentlyWritten) {\n logger.debug(`gc, keeping ${recentlyWritten} objects that were written too recently to judge`);\n }\n\n const strayFiles = await removeStrayTempFiles(repo.getPath(), dryRun);\n\n const deletedObjects = versionRefsToDelete.length + sourceRefsToDelete.length;\n if (!dryRun && deletedObjects) {\n const remove = async (refs: Ref[]) => {\n if (!refs.length) return;\n if (backup) await repo.moveObjectsToDir(refs, DELETED_OBJECTS_DIR);\n else await repo.deleteObjectsFromFS(refs);\n };\n logger.debug(`gc, ${backup ? 'moving' : 'deleting'} ${deletedObjects} objects`);\n // versions first, and only then the files they point at - two passes, because each one deletes\n // concurrently and nothing here is transactional. a run that dies partway through, or a single\n // filesystem error, leaves whatever it had finished. this way that is a source with no version,\n // which the next run collects; the other way round it is a version whose files are gone, which\n // reads as fully cached, is never re-fetched and is never repaired.\n await remove(versionRefsToDelete);\n await remove(sourceRefsToDelete);\n }\n\n return {\n dryRun,\n backupDir: backup && !dryRun && deletedObjects ? path.join(scope.path, DELETED_OBJECTS_DIR) : undefined,\n backup,\n totalObjects: allObjects.length,\n totalSize: totalSize + strayFiles.size + backupDirSize + retainedDirsSize,\n deletedObjects,\n deletedSize,\n deletedByType,\n keptVersions: rootVersions.size,\n strayFiles: strayFiles.count,\n strayFilesSize: strayFiles.size,\n backupDirSize,\n retainedDirsSize,\n };\n\n /**\n * walk back from a bare hash through `Version.parents`, keeping every ancestor still here.\n *\n * this is what `keepHistoryOf` does for the heads it can attribute to a component. a\n * staged snap, a stash and an unmerged head are hashes on their own, so the chain is followed\n * directly - and stops at the same boundary, a snap the remote already has. past that point the\n * history is re-fetchable, which is the history this collector exists to prune.\n */\n async function keepAncestryOf(hashes: string[], { stopAtRemote = true } = {}) {\n const seen = new Set<string>();\n const queue = [...hashes];\n while (queue.length) {\n const hash = queue.pop() as string;\n if (seen.has(hash)) continue;\n seen.add(hash);\n // a hash we don't have marks the edge of what was ever fetched - nothing to keep or walk\n if (!versionHashes.has(hash)) continue;\n addRoot(hash);\n if (stopAtRemote && remoteRefs.has(hash)) continue;\n const version = (await Ref.from(hash).load(repo)) as Version | undefined;\n if (!version) continue;\n version.parents.forEach((parent) => queue.push(parent.toString()));\n }\n }\n\n /**\n * keep the history behind each head, walked through its component. `stopAtRemote` ends each walk\n * at what the remote already has, which is what makes it the unexported part; `limit` keeps only\n * the first N versions, which the traversal returns head first.\n */\n async function keepHistoryOf(startingPoints: ComponentHead[], { stopAtRemote = false, limit = Infinity } = {}) {\n await pMapPool(\n startingPoints,\n async ({ component, head }) => {\n if (!head) return;\n const remoteHeads = stopAtRemote ? remoteRefsPerComponent.get(componentKey(component)) || [] : undefined;\n if (remoteHeads?.some((remoteHead) => remoteHead.isEqual(head))) return; // nothing local\n const versionsInfo = await getAllVersionsInfo({\n modelComponent: component,\n repo,\n startFrom: head,\n stopAt: remoteHeads,\n throws: false,\n });\n versionsInfo.slice(0, limit).forEach((versionInfo) => addRoot(versionInfo.ref));\n },\n { concurrency }\n );\n }\n\n /**\n * the versions a kept version names elsewhere than in its own file list: its dependencies at the\n * exact version they're pinned to (that's what gets isolated into a capsule on build), the env\n * or aspect it was built with, and the other side of a resolved unrelated merge.\n *\n * `flattenedDependencies` is already transitive, so one pass over it would be enough on its own.\n * the other two are not in anyone's flattened list though, so rooting one adds a version whose\n * own references nothing has accounted for - hence the loop, which runs until a pass adds none.\n *\n * each version is loaded once, here, so this is also where it's expanded into the objects it\n * points at: its files, its build artifacts and its dependency-graph objects. deliberately not\n * its parents - that's the history being pruned. returns the hashes of everything to keep.\n */\n async function keepReferencedVersions(): Promise<Set<string>> {\n const kept = new Set<string>();\n const seen = new Set<string>();\n let frontier = [...rootVersions];\n while (frontier.length) {\n const dependencies = new Set<string>();\n const added: string[] = [];\n await pMapPool(\n frontier,\n async (hash) => {\n const version = (await Ref.from(hash).load(repo)) as Version | undefined;\n if (!version) return;\n kept.add(hash);\n version.refsWithOptions(false, true).forEach((ref) => kept.add(ref.toString()));\n version.flattenedDependencies.forEach((dependency) => dependencies.add(dependency.toString()));\n // an env or aspect the version was built with. versions written by older bits record\n // these only here, so taking `flattenedDependencies` at its word would miss them.\n version.extensions.extensionsBitIds.forEach((extension) => dependencies.add(extension.toString()));\n // the other side of a resolved unrelated merge - a component created on a lane under a\n // name main already had. the diverge calculation loads it before it can tell that it's\n // unrelated, so it has to be here. `refsWithOptions` doesn't report it.\n const unrelatedHead = version.unrelated?.head?.toString();\n if (unrelatedHead && addNewRoot(unrelatedHead)) added.push(unrelatedHead);\n },\n { concurrency }\n );\n await pMapPool(\n [...dependencies].filter((idStr) => !seen.has(idStr)),\n async (idStr) => {\n seen.add(idStr);\n const id = ComponentID.fromString(idStr);\n // a snap dependency names its version by hash, so it stands without the component\n // object. same as the checked-out ids: a missing model must not take it down with it.\n const component = await getComponent(id);\n const hashes = compact([id.version, component?.getRef(id.version as string)?.toString()]);\n // only what is actually here and not walked yet is worth walking\n hashes.forEach((hash) => {\n if (addNewRoot(hash)) added.push(hash);\n });\n },\n { concurrency }\n );\n frontier = added;\n }\n return kept;\n }\n}\n\n/**\n * the hashes `bit stash` is holding. these are snaps that only ever existed here, so losing them\n * loses the stashed work for good - `bit stash load` would ask for a hash no remote has.\n */\nasync function getStashedHashes(scopePath: string): Promise<string[]> {\n const stashDir = path.join(scopePath, STASH_DIR);\n if (!(await fs.pathExists(stashDir))) return [];\n const files = (await fs.readdir(stashDir)).filter((file) => file.endsWith('.json'));\n const hashesPerFile = await Promise.all(\n files.map(async (file) => {\n const filePath = path.join(stashDir, file);\n // the same reasoning as an object we can't classify: a stash file is the only record of the\n // snaps it holds, so failing to make sense of one means we don't know what must survive. an\n // empty list here is reserved for a stash that parsed and genuinely holds nothing.\n const unusable = (reason: string) =>\n new BitError(`unable to read the stash file \"${filePath}\", so it is not safe to run gc.\na stash is the only record of the snaps it holds - they exist nowhere else, and deleting them\ncannot be undone. fix or remove the file and run gc again.\nError: ${reason}`);\n let content: Record<string, any>;\n try {\n content = await fs.readJson(filePath);\n } catch (err: any) {\n throw unusable(err.message);\n }\n // parsing is not the same as understanding. this is the shape `StashData.fromObject` needs,\n // and a file that doesn't have it is one `bit stash load` couldn't read either - so reading\n // it as \"holds no snaps\" is precisely the assumption that would delete them.\n const compsData = content?.stashCompsData;\n if (!Array.isArray(compsData)) throw unusable('\"stashCompsData\" is missing or is not an array');\n return compsData.map((compData, index) => {\n const hash = compData?.hash;\n if (typeof hash !== 'string' || !hash) {\n throw unusable(`the entry at index ${index} of \"stashCompsData\" has no \"hash\"`);\n }\n return hash;\n });\n })\n );\n return hashesPerFile.flat();\n}\n\n/**\n * bring back everything sitting in the backup directory.\n *\n * successive --backup runs add to that directory rather than replace it, on the grounds that\n * throwing away an earlier backup to make room for a later one is the more expensive mistake. so\n * this restores every run that is still backed up, not only the last one.\n *\n * the directory is removed once its contents are back in the scope. leaving it would hold on to a\n * second copy of every object - the disk space this command exists to reclaim - and would let a\n * later restore replay objects that a gc since then deliberately removed.\n *\n * it is moved aside before anything is copied, rather than emptied in place. a `--backup` running\n * at the same time then writes into a fresh `deleted-objects` that this restore neither copies from\n * nor deletes; otherwise objects moved there mid-restore would be removed from the backup without\n * ever having been brought back. the move is a rename within the scope directory, so it is atomic.\n */\nexport async function restoreDeletedObjects(scope: Scope, overwrite = false) {\n const deletedObjectsDir = path.join(scope.path, DELETED_OBJECTS_DIR);\n // a directory left behind by a restore that was interrupted after the rename. its contents never\n // made it back, and nothing else will look for them, so they are picked up here.\n const leftovers = await glob(`${DELETED_OBJECTS_DIR}.restoring-*`, { cwd: scope.path });\n // each one is claimed by renaming it again, under a name only this call knows. a second restore\n // running at the same time finds the old name gone and moves on, rather than both copying from a\n // directory one of them is about to remove.\n const staged: string[] = [];\n const claim = async (dir: string): Promise<string | undefined> => {\n const claimed = `${DELETED_OBJECTS_DIR}.restoring-${Date.now()}-${process.pid}-${staged.length}`;\n try {\n await fs.move(path.join(scope.path, dir), path.join(scope.path, claimed));\n } catch {\n return undefined; // someone else got there first\n }\n return claimed;\n };\n for (const dir of [...leftovers, DELETED_OBJECTS_DIR]) {\n const claimed = await claim(dir);\n if (claimed) staged.push(claimed);\n }\n if (!staged.length) {\n throw new BitError(`there is nothing to restore, \"${deletedObjectsDir}\" doesn't exist.\nit is only created by a garbage collection that ran with --backup`);\n }\n for (const stagingDir of staged) {\n try {\n await scope.objects.restoreFromDir(stagingDir, overwrite);\n } catch (err: any) {\n // put it back under the name the next `--restore` will look for, so a failure here doesn't\n // leave the objects somewhere nothing goes looking.\n if (!(await fs.pathExists(deletedObjectsDir))) {\n await fs.move(path.join(scope.path, stagingDir), deletedObjectsDir);\n }\n throw err;\n }\n await fs.remove(path.join(scope.path, stagingDir));\n }\n}\n\n/** total bytes under a directory, or 0 if it isn't there */\nasync function getDirSize(dirPath: string): Promise<number> {\n if (!(await fs.pathExists(dirPath))) return 0;\n const files = await glob('**/*', { cwd: dirPath, nodir: true, dot: true });\n // pooled like every other walk here: a backup or a trash can hold as many files as the scope\n // itself, and one pending stat each is a lot of promises to be holding for a number.\n const sizes = await pMapPool(\n files,\n async (file) => {\n try {\n return (await fs.stat(path.join(dirPath, file))).size;\n } catch {\n return 0;\n }\n },\n { concurrency: concurrentIOLimit() }\n );\n return sizes.reduce((sum, size) => sum + size, 0);\n}\n\n/**\n * the lanes `bit lane remove` put in the trash. they still name the snaps they held, and the trash\n * exists so the lane can be brought back - which it can't be if its objects went in the meantime.\n *\n * only `Lane` objects are of interest; everything else in there is a component or a version that\n * the rest of the root set already speaks for.\n */\nasync function getTrashedLanes(repo: Repository): Promise<Lane[]> {\n const refs = await repo.listTrash();\n if (!refs.length) return [];\n logger.debug(`gc, reading ${refs.length} objects from the trash`);\n try {\n const objects = await repo.getFromTrash(refs);\n return objects.filter((object) => object instanceof Lane) as Lane[];\n } catch (err: any) {\n // same reasoning as a stash we can't read: the trash is a recovery mechanism, and not knowing\n // what's in it means not knowing which snaps a restored lane would come back looking for.\n throw new BitError(`unable to read the trash of the scope, so it is not safe to run gc.\nthe trash holds lanes that \"bit lane remove\" can bring back, and gc needs to know which snaps they\npoint at. empty the trash directory (\"${repo.getTrashDir()}\") if you don't need it, and run again.\nError: ${err.message}`);\n }\n}\n\n/**\n * their size is measured, not only their count: these files are deleted outright (even with\n * --backup, which only applies to objects), so their bytes are part of what the run frees and\n * leaving them out understates it - an interrupted write of a large file is exactly the case where\n * the number matters.\n *\n * only files that have been sitting there a while are touched. a temp file of this shape is also\n * what an object write in progress looks like, and unlinking one out from under another bit\n * process would fail its rename. an interrupted write is old by definition, so waiting costs\n * nothing and the race goes away.\n */\nasync function removeStrayTempFiles(objectsPath: string, dryRun: boolean): Promise<StrayTempFiles> {\n const matches = await glob(path.join('*', '*'), { cwd: objectsPath });\n const candidates = matches.filter((match) => STRAY_TEMP_FILE.test(path.basename(match)));\n if (!candidates.length) return { count: 0, size: 0 };\n const staleBefore = Date.now() - STRAY_TEMP_FILE_MIN_AGE_MS;\n const strays = compact(\n await pMapPool(\n candidates,\n async (candidate) => {\n try {\n const stat = await fs.stat(path.join(objectsPath, candidate));\n // a name is not enough to act on when `fs.remove` would take a whole tree with it. an\n // interrupted write leaves a file; anything else here is not ours to delete.\n if (!stat.isFile()) return null;\n if (stat.mtimeMs > staleBefore) return null;\n return { file: candidate, size: stat.size };\n } catch {\n // it vanished between the glob and the stat - either another process finished its rename\n // or something else cleaned up. either way it's not ours to count or remove.\n return null;\n }\n },\n { concurrency: concurrentIOLimit() }\n )\n );\n if (!strays.length) return { count: 0, size: 0 };\n logger.debug(`gc, ${strays.length} stray temp files of interrupted writes`);\n if (!dryRun) {\n await Promise.all(strays.map(({ file }) => fs.remove(path.join(objectsPath, file))));\n }\n return { count: strays.length, size: strays.reduce((sum, { size }) => sum + size, 0) };\n}\n"],"mappings":";;;;;;;AAAA,SAAAA,SAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,QAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,MAAA;EAAA,MAAAH,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAC,KAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,MAAA;EAAA,MAAAJ,IAAA,GAAAE,OAAA;EAAAE,KAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,QAAA;EAAA,MAAAL,IAAA,GAAAE,OAAA;EAAAG,OAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,UAAA;EAAA,MAAAN,IAAA,GAAAE,OAAA;EAAAI,SAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAO,aAAA;EAAA,MAAAP,IAAA,GAAAE,OAAA;EAAAK,YAAA,YAAAA,CAAA;IAAA,OAAAP,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAQ,QAAA;EAAA,MAAAR,IAAA,GAAAE,OAAA;EAAAM,OAAA,YAAAA,CAAA;IAAA,OAAAR,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAS,gBAAA;EAAA,MAAAT,IAAA,GAAAE,OAAA;EAAAO,eAAA,YAAAA,CAAA;IAAA,OAAAT,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAU,gBAAA;EAAA,MAAAV,IAAA,GAAAE,OA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,CAACC,IAAI,CAACuN,WAAW,EAAE1C,IAAI,CAAC,CAAC,CAAC,CAAC;EACtF;EACA,OAAO;IAAEjD,KAAK,EAAEkG,MAAM,CAACpN,MAAM;IAAEe,IAAI,EAAEqM,MAAM,CAACZ,MAAM,CAAC,CAACC,GAAG,EAAE;MAAE1L;IAAK,CAAC,KAAK0L,GAAG,GAAG1L,IAAI,EAAE,CAAC;EAAE,CAAC;AACxF","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_fsExtra","data","_interopRequireDefault","require","_path","_glob","_lodash","_bitError","_componentId","_legacy","_harmonyModules","_toolboxPromise","_objects","_component","_legacy2","e","__esModule","default","STRAY_TEMP_FILE","STRAY_TEMP_FILE_MIN_AGE_MS","RECENT_WRITE_MARGIN_MS","STASH_DIR","collectGarbageInWorkspace","scope","workspaceIds","opts","dryRun","verbose","keepVersions","backup","repo","objects","concurrency","concurrentIOLimit","startedAt","Date","now","backupDirSize","trashSize","stashSize","Promise","all","getDirSize","path","join","DELETED_OBJECTS_DIR","getTrashDir","retainedDirsSize","logger","debug","name","allObjects","unreadable","listObjectsWithType","length","list","map","ref","objectPath","BitError","versionHashes","Set","refsByType","Map","recentlyWrittenVersions","settledBefore","totalSize","forEach","type","size","mtimeMs","Version","add","toString","push","existing","get","set","entries","t","r","rootVersions","addRoot","hash","has","addNewRoot","componentKey","component","toComponentId","toStringWithoutVersion","loadObjectsOfType","refs","pMapPool","load","compact","components","ModelComponent","liveLanes","Lane","lanes","getTrashedLanes","componentsById","getComponent","id","getModelComponentIfExist","changeVersion","undefined","detachedHeads","getHead","getAllHeads","head","Object","values","orphanedVersions","checkedOutHeads","workspaceComponents","version","checkedOut","hasVersion","getRef","workspaceComponentIds","laneHeads","unattachedLaneHeads","lane","toComponentIdsIncludeUpdateDependents","Ref","from","readmeComponent","laneHistories","LaneHistory","laneHistory","getHistory","item","ids","deleted","updateDependents","idStr","ComponentID","fromString","remoteRefsPerComponent","remoteLanes","getAllRefsPerComponent","remoteRefs","bareRoots","stagedSnaps","getAll","getStashedHashes","keepAncestryOf","unmergedRoots","unmergedComponents","getComponents","flatMap","unmerged","unrelated","headOnCurrentLane","unrelatedHead","stopAtRemote","keepHistoryOf","filter","limit","keep","keepReferencedVersions","versionRefsToDelete","sourceRefsToDelete","deletedByType","deletedSize","recentlyWritten","Source","count","console","strayFiles","removeStrayTempFiles","getPath","deletedObjects","remove","moveObjectsToDir","deleteObjectsFromFS","backupDir","totalObjects","keptVersions","strayFilesSize","hashes","seen","queue","pop","parents","parent","startingPoints","Infinity","remoteHeads","some","remoteHead","isEqual","versionsInfo","getAllVersionsInfo","modelComponent","startFrom","stopAt","throws","slice","versionInfo","kept","frontier","dependencies","added","refsWithOptions","flattenedDependencies","loadFlattenedDependencies","dependency","extensions","extensionsBitIds","extension","scopePath","stashDir","fs","pathExists","files","readdir","file","endsWith","hashesPerFile","filePath","unusable","reason","content","readJson","err","message","compsData","stashCompsData","Array","isArray","compData","index","flat","restoreDeletedObjects","overwrite","deletedObjectsDir","leftovers","glob","cwd","staged","claim","dir","claimed","process","pid","move","stagingDir","restoreFromDir","dirPath","nodir","dot","sizes","stat","reduce","sum","listTrash","getFromTrash","object","objectsPath","matches","candidates","match","test","basename","staleBefore","strays","candidate","isFile"],"sources":["workspace-garbage-collector.ts"],"sourcesContent":["import fs from 'fs-extra';\nimport path from 'path';\nimport { glob } from 'glob';\nimport { compact } from 'lodash';\nimport { BitError } from '@teambit/bit-error';\nimport { ComponentID } from '@teambit/component-id';\nimport { logger } from '@teambit/legacy.logger';\nimport { concurrentIOLimit } from '@teambit/harmony.modules.concurrency';\nimport { pMapPool } from '@teambit/toolbox.promise.map-pool';\nimport type { Repository } from '@teambit/objects';\nimport { Lane, LaneHistory, ModelComponent, Ref, Source, Version } from '@teambit/objects';\nimport { getAllVersionsInfo } from '@teambit/component.snap-distance';\nimport type { Scope } from '@teambit/legacy.scope';\nimport { DELETED_OBJECTS_DIR } from '@teambit/legacy.scope';\n\n/**\n * a leftover of an interrupted atomic write - `<38-hex>.<pid-ish digits>` next to the object it was\n * about to become. `Repository.listRefs` skips them (they're not valid object paths), so nothing\n * ever cleans them up.\n */\nconst STRAY_TEMP_FILE = /^[0-9a-f]{38}\\.\\d+$/;\n\n/**\n * how long a file of that shape has to have been sitting there before it counts as abandoned\n * rather than as a write someone is in the middle of.\n */\nconst STRAY_TEMP_FILE_MIN_AGE_MS = 60 * 60 * 1000;\n\n/**\n * how recently an object must have been written for this run to decline to judge it. covers the\n * gap between another process writing a `Version` and pointing a `ModelComponent` at it.\n */\nconst RECENT_WRITE_MARGIN_MS = 5 * 60 * 1000;\n\n/**\n * `bit stash` writes a `Version` object into the local scope and records only its hash in a file\n * here. deliberately nothing else refers to it - not the component, not a lane, not `.bitmap`.\n */\nconst STASH_DIR = 'stash';\n\nexport type WorkspaceGcOptions = {\n dryRun?: boolean;\n verbose?: boolean;\n /**\n * in addition to the version each component is checked out at, keep the last N versions of every\n * workspace component, so their recent history (`bit log`, `bit blame`, `bit diff`) stays local.\n */\n keepVersions?: number;\n /**\n * move the objects into a `deleted-objects` directory instead of deleting them, so that\n * `--restore` can bring them back. note that this doesn't free any disk space.\n */\n backup?: boolean;\n};\n\ntype StrayTempFiles = { count: number; size: number };\n\n/** a head to walk back from, along with the component it belongs to */\ntype ComponentHead = { component: ModelComponent; head?: Ref };\n\nexport type GcResult = {\n dryRun: boolean;\n /** what --backup asked for. `backupDir` only says where objects went, so a dry run has none */\n backup: boolean;\n backupDir?: string;\n totalObjects: number;\n /** everything the scope holds on disk - live objects, stray temp files, trash, stash, backup */\n totalSize: number;\n deletedObjects: number;\n /** the objects only. with --backup these bytes move to the backup directory rather than leave */\n deletedSize: number;\n deletedByType: { [type: string]: { count: number; size: number } };\n keptVersions: number;\n strayFiles: number;\n /** freed regardless of --backup, which applies to objects only */\n strayFilesSize: number;\n /** what earlier --backup runs left behind, measured before this one moves anything into it */\n backupDirSize: number;\n /** the trash and the stash, which are part of the scope's weight but never freed by gc */\n retainedDirsSize: number;\n};\n\n/**\n * remove objects a workspace doesn't need from its local scope.\n *\n * a workspace accumulates objects indefinitely: every `bit import` brings the new head of each\n * component along with the source files of that version, and nothing ever removes the versions\n * that were superseded. after a while the bulk of the scope is file contents of versions no one\n * will ever ask for again.\n *\n * unlike the garbage collector that runs on a bare (remote) scope, this one is not bound to keep\n * history: a workspace scope is a cache, not the source of truth. anything deleted here can be\n * re-fetched from the remote, and `sources.get()` already checks whether the specific `Version`\n * object exists locally before deciding it has nothing to fetch.\n *\n * that last point is why versions are pruned whole - the `Version` object together with the\n * `Source` objects it points to. keeping a `Version` whose file contents were deleted would look\n * to the importer exactly like a version that's fully present, so it would skip the fetch and only\n * fail later, when something tries to read the files.\n *\n * the scope itself knows nothing about workspaces. it's given the ids that are in use and the\n * hashes that must survive; deciding what those are is this aspect's job.\n */\nexport async function collectGarbageInWorkspace(\n scope: Scope,\n workspaceIds: ComponentID[],\n opts: WorkspaceGcOptions = {}\n): Promise<GcResult> {\n const { dryRun = false, verbose = false, keepVersions = 0, backup = false } = opts;\n const repo = scope.objects;\n const concurrency = concurrentIOLimit();\n // taken before anything is read, so it's never later than the inventory it will be compared to\n const startedAt = Date.now();\n\n // measured before anything moves into it, so this run's own objects are not counted twice - they\n // are still in `objects/` when the inventory below is taken. the trash and the stash are here for\n // the same reason the backup directory is: they sit inside the scope and weigh what they weigh,\n // and a report that leaves them out has the scope shrinking while the disk does not. gc frees\n // none of the three, so they stay on both sides of the before/after.\n const [backupDirSize, trashSize, stashSize] = await Promise.all([\n getDirSize(path.join(scope.path, DELETED_OBJECTS_DIR)),\n getDirSize(repo.getTrashDir()),\n getDirSize(path.join(scope.path, STASH_DIR)),\n ]);\n const retainedDirsSize = trashSize + stashSize;\n\n logger.debug(`gc, classifying the objects of ${scope.name}`);\n const { objects: allObjects, unreadable } = await repo.listObjectsWithType();\n\n // an object we couldn't classify is an object we can't reason about. if it happens to be a live\n // `Version`, we'd never learn which `Source` objects it points at, and would delete them while\n // leaving the version in place - the one state this collector exists to avoid. so rather than\n // deleting from a partial inventory, refuse to delete at all.\n if (unreadable.length) {\n const list = unreadable.map((ref) => ` ${repo.objectPath(ref)}`).join('\\n');\n throw new BitError(`unable to read ${unreadable.length} object(s) in the scope, so it is not safe to run gc.\nthese objects are most likely corrupted. bit can fetch them again from the remote, so it is safe to\ndelete them and run gc again:\n${list}`);\n }\n\n const versionHashes = new Set<string>();\n const refsByType = new Map<string, Ref[]>();\n const recentlyWrittenVersions: string[] = [];\n const settledBefore = startedAt - RECENT_WRITE_MARGIN_MS;\n let totalSize = 0;\n allObjects.forEach(({ ref, type, size, mtimeMs }) => {\n totalSize += size;\n if (type === Version.name) {\n versionHashes.add(ref.toString());\n if (mtimeMs > settledBefore) recentlyWrittenVersions.push(ref.toString());\n }\n const existing = refsByType.get(type);\n if (existing) existing.push(ref);\n else refsByType.set(type, [ref]);\n });\n logger.debug(\n `gc, ${allObjects.length} objects: ${[...refsByType.entries()].map(([t, r]) => `${t}:${r.length}`).join(', ')}`\n );\n\n /**\n * the versions to keep in full. a hash is only accepted if a `Version` object with that hash is\n * actually here - a head pointing at something we never fetched is not our problem to keep.\n */\n const rootVersions = new Set<string>();\n const addRoot = (ref?: Ref | string | null) => {\n if (!ref) return;\n const hash = ref.toString();\n if (versionHashes.has(hash)) rootVersions.add(hash);\n };\n /** `addRoot`, reporting whether the hash is a root only as of this call - i.e. one still to walk */\n const addNewRoot = (hash: string): boolean => {\n if (rootVersions.has(hash)) return false;\n addRoot(hash);\n return rootVersions.has(hash);\n };\n const componentKey = (component: ModelComponent) => component.toComponentId().toStringWithoutVersion();\n\n const loadObjectsOfType = async <T>(type: string): Promise<T[]> => {\n const refs = refsByType.get(type) || [];\n const objects = await pMapPool(refs, (ref) => ref.load(repo), { concurrency });\n return compact(objects) as T[];\n };\n\n const components = await loadObjectsOfType<ModelComponent>(ModelComponent.name);\n const liveLanes = await loadObjectsOfType<Lane>(Lane.name);\n // `bit lane remove` moves the `Lane` object to the trash rather than deleting it, so that it can\n // be brought back. a lane sitting there still names the snaps it held, and if those are gone the\n // lane comes back empty-handed. the collector for bare scopes has always counted them; this one\n // has the same reason to.\n const lanes = [...liveLanes, ...(await getTrashedLanes(repo))];\n const componentsById = new Map(components.map((component) => [componentKey(component), component]));\n // every component object has just been loaded, so going back through the scope is only for the\n // one it can't be matched to by id - a symlink, say.\n const getComponent = async (id: ComponentID): Promise<ModelComponent | undefined> =>\n componentsById.get(id.toStringWithoutVersion()) || scope.getModelComponentIfExist(id.changeVersion(undefined));\n\n // the head of every component. `bit log`, `bit status` and the diverge calculation all start\n // there, and it's what `VersionHistory` is repaired from when it turns out to be incomplete.\n const detachedHeads: ComponentHead[] = [];\n components.forEach((component) => {\n addRoot(component.getHead());\n component.detachedHeads.getAllHeads().forEach((head) => {\n addRoot(head);\n detachedHeads.push({ component, head });\n });\n // an orphaned tag reached this scope through some other remote's cache rather than through the\n // component's origin, which is the whole reason bit holds on to it locally. re-fetching it is\n // not something we can count on, so it is treated like anything else that exists only here.\n Object.values(component.orphanedVersions).forEach(addRoot);\n });\n\n // the version each workspace component is checked out at - `bit status` diffs the working\n // directory against it, so it's read on virtually every command. kept for `--keep-versions` too.\n const checkedOutHeads: ComponentHead[] = [];\n const workspaceComponents = compact(\n await pMapPool(\n workspaceIds,\n async (id) => {\n // a snap id is already the hash, so it stands on its own. rooting it before the lookup\n // means a component object that is missing or unreadable can't take the version the\n // workspace is sitting on down with it. a tag resolves through the component below.\n addRoot(id.version);\n const component = await getComponent(id);\n if (!component) return null;\n // the head is the fallback for a version the component can't resolve - a lane snap, say,\n // which `addRoot(id.version)` above has already taken care of on its own.\n const checkedOut =\n (id.hasVersion() ? component.getRef(id.version as string) : undefined) || component.getHead();\n addRoot(checkedOut);\n if (checkedOut) checkedOutHeads.push({ component, head: checkedOut });\n return component;\n },\n { concurrency }\n )\n );\n const workspaceComponentIds = new Set(workspaceComponents.map(componentKey));\n\n // heads of every component on every local lane, `updateDependents` included.\n const laneHeads: ComponentHead[] = [];\n /** lane heads whose component object isn't here, so `keepHistoryOf` can't walk them */\n const unattachedLaneHeads: string[] = [];\n lanes.forEach((lane) => {\n lane.toComponentIdsIncludeUpdateDependents().forEach((id) => {\n addRoot(id.version);\n if (!id.version) return;\n const component = componentsById.get(id.toStringWithoutVersion());\n // without a component the tip would be rooted on its own and its chain left to the deletion\n // pass, which is the wrong half to keep for a lane that was never exported.\n if (component) laneHeads.push({ component, head: Ref.from(id.version) });\n else unattachedLaneHeads.push(id.version);\n });\n // the lane's readme is pointed at separately and needn't be among the components above\n addRoot(lane.readmeComponent?.head);\n });\n\n // `bit lane history` can check out or revert to any entry it recorded, and it hands checkout the\n // exact versions written there. a version that has since left the lane is reachable from nothing\n // else, and on a lane that was never exported it is here and nowhere else.\n const laneHistories = await loadObjectsOfType<LaneHistory>(LaneHistory.name);\n laneHistories.forEach((laneHistory) => {\n Object.values(laneHistory.getHistory()).forEach((item) => {\n const ids = [...item.components, ...(item.deleted || []), ...(item.updateDependents || [])];\n ids.forEach((idStr) => addRoot(ComponentID.fromString(idStr).version));\n });\n });\n\n // heads we track for remotes. deleting one would break the diverge calculation, which can no\n // longer reach it and has no way to tell that it's gone rather than never-fetched.\n const remoteRefsPerComponent = await repo.remoteLanes.getAllRefsPerComponent();\n const remoteRefs = new Set<string>();\n remoteRefsPerComponent.forEach((refs) =>\n refs.forEach((ref) => {\n addRoot(ref);\n remoteRefs.add(ref.toString());\n })\n );\n\n // snaps that were created here and never exported. nothing can bring these back, and for these\n // the tip alone is not enough: export sends the whole chain up to what the remote already has,\n // and `bit stash load` reads the parent of the stashed snap as the base of its three-way merge.\n // they arrive as bare hashes with no component to resolve them against, so the ancestry is\n // walked directly rather than through `keepHistoryOf`.\n const bareRoots = [...scope.stagedSnaps.getAll(), ...(await getStashedHashes(scope.path))];\n await keepAncestryOf([...bareRoots, ...unattachedLaneHeads]);\n\n // a merge that hasn't been resolved yet. the incoming side may have been imported from one scope\n // in order to be exported onward to another, and it's the target's head that bounds what export\n // has to send - not the head of the scope it came from. rather than work out which remote is\n // which, the chain is kept whole: an unresolved merge is a passing state on a handful of\n // components, so keeping more of it than strictly needed costs little and guessing wrong here\n // breaks the merge.\n const unmergedRoots = compact(\n repo.unmergedComponents.getComponents().flatMap((unmerged) => [\n unmerged.head,\n // `unrelated` is a boolean on entries written by older versions, which carry no extra hashes.\n ...(typeof unmerged.unrelated === 'object'\n ? [unmerged.unrelated.headOnCurrentLane, unmerged.unrelated.unrelatedHead]\n : []),\n ])\n ).map((hash) => hash.toString());\n await keepAncestryOf(unmergedRoots, { stopAtRemote: false });\n\n // snaps that were created here and not exported yet must be kept in full, not only their tip -\n // export sends the entire chain up to what the remote already has. `staged-snaps` normally\n // records them, but it's written per-snap and older workspaces predate it, so the chains are\n // walked rather than trusted. a detached head is a tip like any other: its unexported parents are\n // reachable from nowhere else.\n //\n // `getHeadRegardlessOfLane` is of no use here or below: `laneHeadLocal` is populated at runtime\n // by whoever checked the lane out, and these components were loaded straight from the objects.\n await keepHistoryOf(\n [...components.map((component) => ({ component, head: component.getHead() })), ...laneHeads, ...detachedHeads],\n { stopAtRemote: true }\n );\n\n /**\n * a version written around the time this run started is one nobody may be pointing at yet: an\n * import or a snap writes the `Version` and its `Source` objects first and updates the\n * `ModelComponent` after, so a run that reads the components in between sees garbage that isn't.\n *\n * it goes in as a root rather than being skipped when candidates are picked, because that is\n * what carries its `Source` objects with it. sparing the version alone would leave exactly the\n * state this collector exists to avoid - a version that looks complete with its files gone, so\n * the importer never fetches and something fails later trying to read them.\n *\n * this narrows the window rather than closing it. only a scope-wide lock held across every\n * object write would close it, and there is none today. the cost of being wrong is one more run.\n */\n recentlyWrittenVersions.forEach(addRoot);\n\n // `--keep-versions N`. counted back from where the workspace actually sits, which is not always\n // the head: the last N versions of a component checked out behind its head are not the head's.\n // the head is kept regardless, so starting there as well would just double what N means. on a\n // lane the recent history asked for is the lane's, hence its heads too.\n if (keepVersions > 0) {\n await keepHistoryOf(\n [...checkedOutHeads, ...laneHeads.filter(({ component }) => workspaceComponentIds.has(componentKey(component)))],\n { limit: keepVersions }\n );\n }\n\n logger.debug(`gc, ${rootVersions.size} root versions before resolving dependencies`);\n const keep = await keepReferencedVersions();\n logger.debug(`gc, ${rootVersions.size} root versions in total`);\n\n // everything that is neither a Version nor a Source is structural - components, lanes, version\n // histories, scope metadata. together they're a fraction of a percent of the scope and they're\n // what makes the rest of it navigable, so they're never candidates for deletion.\n // split by type so the removal can take the versions first - see below\n const versionRefsToDelete: Ref[] = [];\n const sourceRefsToDelete: Ref[] = [];\n const deletedByType: { [type: string]: { count: number; size: number } } = {};\n let deletedSize = 0;\n /**\n * the other half of the recent-write margin. a fresh `Version` was kept as a root above, which\n * brought its files with it; this catches a `Source` written just before the `Version` that will\n * refer to it, which no root can speak for yet.\n */\n let recentlyWritten = 0;\n allObjects.forEach(({ ref, type, size, mtimeMs }) => {\n if (type !== Version.name && type !== Source.name) return;\n if (keep.has(ref.toString())) return;\n if (mtimeMs > settledBefore) {\n recentlyWritten += 1;\n return;\n }\n if (type === Version.name) versionRefsToDelete.push(ref);\n else sourceRefsToDelete.push(ref);\n deletedSize += size;\n if (!deletedByType[type]) deletedByType[type] = { count: 0, size: 0 };\n deletedByType[type].count += 1;\n deletedByType[type].size += size;\n if (verbose) logger.console(`gc, deleting ${type} ${ref.toString()}`);\n });\n if (recentlyWritten) {\n logger.debug(`gc, keeping ${recentlyWritten} objects that were written too recently to judge`);\n }\n\n const strayFiles = await removeStrayTempFiles(repo.getPath(), dryRun);\n\n const deletedObjects = versionRefsToDelete.length + sourceRefsToDelete.length;\n if (!dryRun && deletedObjects) {\n const remove = async (refs: Ref[]) => {\n if (!refs.length) return;\n if (backup) await repo.moveObjectsToDir(refs, DELETED_OBJECTS_DIR);\n else await repo.deleteObjectsFromFS(refs);\n };\n logger.debug(`gc, ${backup ? 'moving' : 'deleting'} ${deletedObjects} objects`);\n // versions first, and only then the files they point at - two passes, because each one deletes\n // concurrently and nothing here is transactional. a run that dies partway through, or a single\n // filesystem error, leaves whatever it had finished. this way that is a source with no version,\n // which the next run collects; the other way round it is a version whose files are gone, which\n // reads as fully cached, is never re-fetched and is never repaired.\n await remove(versionRefsToDelete);\n await remove(sourceRefsToDelete);\n }\n\n return {\n dryRun,\n backupDir: backup && !dryRun && deletedObjects ? path.join(scope.path, DELETED_OBJECTS_DIR) : undefined,\n backup,\n totalObjects: allObjects.length,\n totalSize: totalSize + strayFiles.size + backupDirSize + retainedDirsSize,\n deletedObjects,\n deletedSize,\n deletedByType,\n keptVersions: rootVersions.size,\n strayFiles: strayFiles.count,\n strayFilesSize: strayFiles.size,\n backupDirSize,\n retainedDirsSize,\n };\n\n /**\n * walk back from a bare hash through `Version.parents`, keeping every ancestor still here.\n *\n * this is what `keepHistoryOf` does for the heads it can attribute to a component. a\n * staged snap, a stash and an unmerged head are hashes on their own, so the chain is followed\n * directly - and stops at the same boundary, a snap the remote already has. past that point the\n * history is re-fetchable, which is the history this collector exists to prune.\n */\n async function keepAncestryOf(hashes: string[], { stopAtRemote = true } = {}) {\n const seen = new Set<string>();\n const queue = [...hashes];\n while (queue.length) {\n const hash = queue.pop() as string;\n if (seen.has(hash)) continue;\n seen.add(hash);\n // a hash we don't have marks the edge of what was ever fetched - nothing to keep or walk\n if (!versionHashes.has(hash)) continue;\n addRoot(hash);\n if (stopAtRemote && remoteRefs.has(hash)) continue;\n const version = (await Ref.from(hash).load(repo)) as Version | undefined;\n if (!version) continue;\n version.parents.forEach((parent) => queue.push(parent.toString()));\n }\n }\n\n /**\n * keep the history behind each head, walked through its component. `stopAtRemote` ends each walk\n * at what the remote already has, which is what makes it the unexported part; `limit` keeps only\n * the first N versions, which the traversal returns head first.\n */\n async function keepHistoryOf(startingPoints: ComponentHead[], { stopAtRemote = false, limit = Infinity } = {}) {\n await pMapPool(\n startingPoints,\n async ({ component, head }) => {\n if (!head) return;\n const remoteHeads = stopAtRemote ? remoteRefsPerComponent.get(componentKey(component)) || [] : undefined;\n if (remoteHeads?.some((remoteHead) => remoteHead.isEqual(head))) return; // nothing local\n const versionsInfo = await getAllVersionsInfo({\n modelComponent: component,\n repo,\n startFrom: head,\n stopAt: remoteHeads,\n throws: false,\n });\n versionsInfo.slice(0, limit).forEach((versionInfo) => addRoot(versionInfo.ref));\n },\n { concurrency }\n );\n }\n\n /**\n * the versions a kept version names elsewhere than in its own file list: its dependencies at the\n * exact version they're pinned to (that's what gets isolated into a capsule on build), the env\n * or aspect it was built with, and the other side of a resolved unrelated merge.\n *\n * `flattenedDependencies` is already transitive, so one pass over it would be enough on its own.\n * the other two are not in anyone's flattened list though, so rooting one adds a version whose\n * own references nothing has accounted for - hence the loop, which runs until a pass adds none.\n *\n * each version is loaded once, here, so this is also where it's expanded into the objects it\n * points at: its files, its build artifacts and its dependency-graph objects. deliberately not\n * its parents - that's the history being pruned. returns the hashes of everything to keep.\n */\n async function keepReferencedVersions(): Promise<Set<string>> {\n const kept = new Set<string>();\n const seen = new Set<string>();\n let frontier = [...rootVersions];\n while (frontier.length) {\n const dependencies = new Set<string>();\n const added: string[] = [];\n await pMapPool(\n frontier,\n async (hash) => {\n const version = (await Ref.from(hash).load(repo)) as Version | undefined;\n if (!version) return;\n kept.add(hash);\n version.refsWithOptions(false, true).forEach((ref) => kept.add(ref.toString()));\n const flattenedDependencies = await version.loadFlattenedDependencies(repo);\n flattenedDependencies.forEach((dependency) => dependencies.add(dependency.toString()));\n // an env or aspect the version was built with. versions written by older bits record\n // these only here, so taking `flattenedDependencies` at its word would miss them.\n version.extensions.extensionsBitIds.forEach((extension) => dependencies.add(extension.toString()));\n // the other side of a resolved unrelated merge - a component created on a lane under a\n // name main already had. the diverge calculation loads it before it can tell that it's\n // unrelated, so it has to be here. `refsWithOptions` doesn't report it.\n const unrelatedHead = version.unrelated?.head?.toString();\n if (unrelatedHead && addNewRoot(unrelatedHead)) added.push(unrelatedHead);\n },\n { concurrency }\n );\n await pMapPool(\n [...dependencies].filter((idStr) => !seen.has(idStr)),\n async (idStr) => {\n seen.add(idStr);\n const id = ComponentID.fromString(idStr);\n // a snap dependency names its version by hash, so it stands without the component\n // object. same as the checked-out ids: a missing model must not take it down with it.\n const component = await getComponent(id);\n const hashes = compact([id.version, component?.getRef(id.version as string)?.toString()]);\n // only what is actually here and not walked yet is worth walking\n hashes.forEach((hash) => {\n if (addNewRoot(hash)) added.push(hash);\n });\n },\n { concurrency }\n );\n frontier = added;\n }\n return kept;\n }\n}\n\n/**\n * the hashes `bit stash` is holding. these are snaps that only ever existed here, so losing them\n * loses the stashed work for good - `bit stash load` would ask for a hash no remote has.\n */\nasync function getStashedHashes(scopePath: string): Promise<string[]> {\n const stashDir = path.join(scopePath, STASH_DIR);\n if (!(await fs.pathExists(stashDir))) return [];\n const files = (await fs.readdir(stashDir)).filter((file) => file.endsWith('.json'));\n const hashesPerFile = await Promise.all(\n files.map(async (file) => {\n const filePath = path.join(stashDir, file);\n // the same reasoning as an object we can't classify: a stash file is the only record of the\n // snaps it holds, so failing to make sense of one means we don't know what must survive. an\n // empty list here is reserved for a stash that parsed and genuinely holds nothing.\n const unusable = (reason: string) =>\n new BitError(`unable to read the stash file \"${filePath}\", so it is not safe to run gc.\na stash is the only record of the snaps it holds - they exist nowhere else, and deleting them\ncannot be undone. fix or remove the file and run gc again.\nError: ${reason}`);\n let content: Record<string, any>;\n try {\n content = await fs.readJson(filePath);\n } catch (err: any) {\n throw unusable(err.message);\n }\n // parsing is not the same as understanding. this is the shape `StashData.fromObject` needs,\n // and a file that doesn't have it is one `bit stash load` couldn't read either - so reading\n // it as \"holds no snaps\" is precisely the assumption that would delete them.\n const compsData = content?.stashCompsData;\n if (!Array.isArray(compsData)) throw unusable('\"stashCompsData\" is missing or is not an array');\n return compsData.map((compData, index) => {\n const hash = compData?.hash;\n if (typeof hash !== 'string' || !hash) {\n throw unusable(`the entry at index ${index} of \"stashCompsData\" has no \"hash\"`);\n }\n return hash;\n });\n })\n );\n return hashesPerFile.flat();\n}\n\n/**\n * bring back everything sitting in the backup directory.\n *\n * successive --backup runs add to that directory rather than replace it, on the grounds that\n * throwing away an earlier backup to make room for a later one is the more expensive mistake. so\n * this restores every run that is still backed up, not only the last one.\n *\n * the directory is removed once its contents are back in the scope. leaving it would hold on to a\n * second copy of every object - the disk space this command exists to reclaim - and would let a\n * later restore replay objects that a gc since then deliberately removed.\n *\n * it is moved aside before anything is copied, rather than emptied in place. a `--backup` running\n * at the same time then writes into a fresh `deleted-objects` that this restore neither copies from\n * nor deletes; otherwise objects moved there mid-restore would be removed from the backup without\n * ever having been brought back. the move is a rename within the scope directory, so it is atomic.\n */\nexport async function restoreDeletedObjects(scope: Scope, overwrite = false) {\n const deletedObjectsDir = path.join(scope.path, DELETED_OBJECTS_DIR);\n // a directory left behind by a restore that was interrupted after the rename. its contents never\n // made it back, and nothing else will look for them, so they are picked up here.\n const leftovers = await glob(`${DELETED_OBJECTS_DIR}.restoring-*`, { cwd: scope.path });\n // each one is claimed by renaming it again, under a name only this call knows. a second restore\n // running at the same time finds the old name gone and moves on, rather than both copying from a\n // directory one of them is about to remove.\n const staged: string[] = [];\n const claim = async (dir: string): Promise<string | undefined> => {\n const claimed = `${DELETED_OBJECTS_DIR}.restoring-${Date.now()}-${process.pid}-${staged.length}`;\n try {\n await fs.move(path.join(scope.path, dir), path.join(scope.path, claimed));\n } catch {\n return undefined; // someone else got there first\n }\n return claimed;\n };\n for (const dir of [...leftovers, DELETED_OBJECTS_DIR]) {\n const claimed = await claim(dir);\n if (claimed) staged.push(claimed);\n }\n if (!staged.length) {\n throw new BitError(`there is nothing to restore, \"${deletedObjectsDir}\" doesn't exist.\nit is only created by a garbage collection that ran with --backup`);\n }\n for (const stagingDir of staged) {\n try {\n await scope.objects.restoreFromDir(stagingDir, overwrite);\n } catch (err: any) {\n // put it back under the name the next `--restore` will look for, so a failure here doesn't\n // leave the objects somewhere nothing goes looking.\n if (!(await fs.pathExists(deletedObjectsDir))) {\n await fs.move(path.join(scope.path, stagingDir), deletedObjectsDir);\n }\n throw err;\n }\n await fs.remove(path.join(scope.path, stagingDir));\n }\n}\n\n/** total bytes under a directory, or 0 if it isn't there */\nasync function getDirSize(dirPath: string): Promise<number> {\n if (!(await fs.pathExists(dirPath))) return 0;\n const files = await glob('**/*', { cwd: dirPath, nodir: true, dot: true });\n // pooled like every other walk here: a backup or a trash can hold as many files as the scope\n // itself, and one pending stat each is a lot of promises to be holding for a number.\n const sizes = await pMapPool(\n files,\n async (file) => {\n try {\n return (await fs.stat(path.join(dirPath, file))).size;\n } catch {\n return 0;\n }\n },\n { concurrency: concurrentIOLimit() }\n );\n return sizes.reduce((sum, size) => sum + size, 0);\n}\n\n/**\n * the lanes `bit lane remove` put in the trash. they still name the snaps they held, and the trash\n * exists so the lane can be brought back - which it can't be if its objects went in the meantime.\n *\n * only `Lane` objects are of interest; everything else in there is a component or a version that\n * the rest of the root set already speaks for.\n */\nasync function getTrashedLanes(repo: Repository): Promise<Lane[]> {\n const refs = await repo.listTrash();\n if (!refs.length) return [];\n logger.debug(`gc, reading ${refs.length} objects from the trash`);\n try {\n const objects = await repo.getFromTrash(refs);\n return objects.filter((object) => object instanceof Lane) as Lane[];\n } catch (err: any) {\n // same reasoning as a stash we can't read: the trash is a recovery mechanism, and not knowing\n // what's in it means not knowing which snaps a restored lane would come back looking for.\n throw new BitError(`unable to read the trash of the scope, so it is not safe to run gc.\nthe trash holds lanes that \"bit lane remove\" can bring back, and gc needs to know which snaps they\npoint at. empty the trash directory (\"${repo.getTrashDir()}\") if you don't need it, and run again.\nError: ${err.message}`);\n }\n}\n\n/**\n * their size is measured, not only their count: these files are deleted outright (even with\n * --backup, which only applies to objects), so their bytes are part of what the run frees and\n * leaving them out understates it - an interrupted write of a large file is exactly the case where\n * the number matters.\n *\n * only files that have been sitting there a while are touched. a temp file of this shape is also\n * what an object write in progress looks like, and unlinking one out from under another bit\n * process would fail its rename. an interrupted write is old by definition, so waiting costs\n * nothing and the race goes away.\n */\nasync function removeStrayTempFiles(objectsPath: string, dryRun: boolean): Promise<StrayTempFiles> {\n const matches = await glob(path.join('*', '*'), { cwd: objectsPath });\n const candidates = matches.filter((match) => STRAY_TEMP_FILE.test(path.basename(match)));\n if (!candidates.length) return { count: 0, size: 0 };\n const staleBefore = Date.now() - STRAY_TEMP_FILE_MIN_AGE_MS;\n const strays = compact(\n await pMapPool(\n candidates,\n async (candidate) => {\n try {\n const stat = await fs.stat(path.join(objectsPath, candidate));\n // a name is not enough to act on when `fs.remove` would take a whole tree with it. an\n // interrupted write leaves a file; anything else here is not ours to delete.\n if (!stat.isFile()) return null;\n if (stat.mtimeMs > staleBefore) return null;\n return { file: candidate, size: stat.size };\n } catch {\n // it vanished between the glob and the stat - either another process finished its rename\n // or something else cleaned up. either way it's not ours to count or remove.\n return null;\n }\n },\n { concurrency: concurrentIOLimit() }\n )\n );\n if (!strays.length) return { count: 0, size: 0 };\n logger.debug(`gc, ${strays.length} stray temp files of interrupted writes`);\n if (!dryRun) {\n await Promise.all(strays.map(({ file }) => fs.remove(path.join(objectsPath, file))));\n }\n return { count: strays.length, size: strays.reduce((sum, { size }) => sum + size, 0) };\n}\n"],"mappings":";;;;;;;AAAA,SAAAA,SAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,QAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,MAAA;EAAA,MAAAH,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAC,KAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,MAAA;EAAA,MAAAJ,IAAA,GAAAE,OAAA;EAAAE,KAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,QAAA;EAAA,MAAAL,IAAA,GAAAE,OAAA;EAAAG,OAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA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IAAI;MAC/B,IAAIf,IAAI,CAACxL,OAAO,GAAGoM,WAAW,EAAE,OAAO,IAAI;MAC3C,OAAO;QAAEhD,IAAI,EAAEkD,SAAS;QAAEvM,IAAI,EAAEyL,IAAI,CAACzL;MAAK,CAAC;IAC7C,CAAC,CAAC,MAAM;MACN;MACA;MACA,OAAO,IAAI;IACb;EACF,CAAC,EACD;IAAErC,WAAW,EAAE,IAAAC,mCAAiB,EAAC;EAAE,CACrC,CACF,CAAC;EACD,IAAI,CAAC0O,MAAM,CAACrN,MAAM,EAAE,OAAO;IAAEkH,KAAK,EAAE,CAAC;IAAEnG,IAAI,EAAE;EAAE,CAAC;EAChDrB,gBAAM,CAACC,KAAK,CAAC,OAAO0N,MAAM,CAACrN,MAAM,yCAAyC,CAAC;EAC3E,IAAI,CAAC5B,MAAM,EAAE;IACX,MAAMc,OAAO,CAACC,GAAG,CAACkO,MAAM,CAACnN,GAAG,CAAC,CAAC;MAAEkK;IAAK,CAAC,KAAKJ,kBAAE,CAACxC,MAAM,CAACnI,eAAI,CAACC,IAAI,CAACwN,WAAW,EAAE1C,IAAI,CAAC,CAAC,CAAC,CAAC;EACtF;EACA,OAAO;IAAElD,KAAK,EAAEmG,MAAM,CAACrN,MAAM;IAAEe,IAAI,EAAEsM,MAAM,CAACZ,MAAM,CAAC,CAACC,GAAG,EAAE;MAAE3L;IAAK,CAAC,KAAK2L,GAAG,GAAG3L,IAAI,EAAE,CAAC;EAAE,CAAC;AACxF","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/clear-cache",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.621",
|
|
4
4
|
"homepage": "https://bit.cloud/teambit/workspace/clear-cache",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.workspace",
|
|
8
8
|
"name": "clear-cache",
|
|
9
|
-
"version": "0.0.
|
|
9
|
+
"version": "0.0.621"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"fs-extra": "10.0.0",
|
|
@@ -17,16 +17,16 @@
|
|
|
17
17
|
"@teambit/bit-error": "0.0.404",
|
|
18
18
|
"@teambit/harmony.modules.runtimes": "0.0.4",
|
|
19
19
|
"@teambit/scope.modules.find-scope-path": "0.0.51",
|
|
20
|
+
"@teambit/workspace.modules.fs-cache": "0.0.87",
|
|
20
21
|
"@teambit/workspace.modules.workspace-locator": "0.0.50",
|
|
21
22
|
"@teambit/component-id": "1.2.5",
|
|
22
23
|
"@teambit/harmony.modules.concurrency": "0.0.50",
|
|
23
|
-
"@teambit/legacy.consumer": "0.0.179",
|
|
24
|
-
"@teambit/legacy.scope": "0.0.179",
|
|
25
|
-
"@teambit/scope.remotes": "0.0.179",
|
|
26
|
-
"@teambit/workspace.modules.fs-cache": "0.0.86",
|
|
27
|
-
"@teambit/component.snap-distance": "0.0.180",
|
|
28
24
|
"@teambit/legacy.logger": "0.0.67",
|
|
29
|
-
"@teambit/toolbox.promise.map-pool": "0.0.24"
|
|
25
|
+
"@teambit/toolbox.promise.map-pool": "0.0.24",
|
|
26
|
+
"@teambit/legacy.consumer": "0.0.181",
|
|
27
|
+
"@teambit/legacy.scope": "0.0.181",
|
|
28
|
+
"@teambit/scope.remotes": "0.0.181",
|
|
29
|
+
"@teambit/component.snap-distance": "0.0.182"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@types/fs-extra": "9.0.7",
|