@prisma/fetch-engine 6.1.0-dev.3 → 6.1.0-dev.5

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.
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var chunk_FKKOTNO6_exports = {};
30
+ __export(chunk_FKKOTNO6_exports, {
31
+ cleanupCache: () => cleanupCache
32
+ });
33
+ module.exports = __toCommonJS(chunk_FKKOTNO6_exports);
34
+ var import_chunk_ZAFWMCVK = require("./chunk-ZAFWMCVK.js");
35
+ var import_chunk_G7EM4XDM = require("./chunk-G7EM4XDM.js");
36
+ var import_chunk_AH6QHEOA = require("./chunk-AH6QHEOA.js");
37
+ var import_debug = __toESM(require("@prisma/debug"));
38
+ var import_fs = __toESM(require("fs"));
39
+ var import_path = __toESM(require("path"));
40
+ var import_util = require("util");
41
+ var import_p_map = (0, import_chunk_AH6QHEOA.__toESM)((0, import_chunk_ZAFWMCVK.require_p_map)());
42
+ var import_rimraf = (0, import_chunk_AH6QHEOA.__toESM)((0, import_chunk_ZAFWMCVK.require_rimraf)());
43
+ var debug = (0, import_debug.default)("cleanupCache");
44
+ var del = (0, import_util.promisify)(import_rimraf.default);
45
+ async function cleanupCache(n = 5) {
46
+ try {
47
+ const rootCacheDir = await (0, import_chunk_G7EM4XDM.getRootCacheDir)();
48
+ if (!rootCacheDir) {
49
+ debug("no rootCacheDir found");
50
+ return;
51
+ }
52
+ const channel = "master";
53
+ const cacheDir = import_path.default.join(rootCacheDir, channel);
54
+ const dirs = await import_fs.default.promises.readdir(cacheDir);
55
+ const dirsWithMeta = await Promise.all(
56
+ dirs.map(async (dirName) => {
57
+ const dir = import_path.default.join(cacheDir, dirName);
58
+ const statResult = await import_fs.default.promises.stat(dir);
59
+ return {
60
+ dir,
61
+ created: statResult.birthtime
62
+ };
63
+ })
64
+ );
65
+ dirsWithMeta.sort((a, b) => a.created < b.created ? 1 : -1);
66
+ const dirsToRemove = dirsWithMeta.slice(n);
67
+ await (0, import_p_map.default)(dirsToRemove, (dir) => del(dir.dir), { concurrency: 20 });
68
+ } catch (e) {
69
+ }
70
+ }