Files
windmill/cli/store.ts
T
Kai Jellinghaus adf991cd2d feat!(cli): Folders support & Less Tarball nesting (#1040)
* Basic folder support

* Proper Folder Support + deps.ts

* Upgrade Versions

* Add folder meta to tarball

* Remove tarball folders

* Minor fixes

* Fix typo

* Remove extra_perms check

* Use new endpoint

* Use new untar location

* Fix shrinking files
2022-12-23 03:06:12 +01:00

28 lines
717 B
TypeScript

import { dir, ensureDir } from "./deps.ts";
function hash_string(str: string): number {
let hash = 0,
i,
chr;
if (str.length === 0) return hash;
for (i = 0; i < str.length; i++) {
chr = str.charCodeAt(i);
hash = (hash << 5) - hash + chr;
hash |= 0; // Convert to 32bit integer
}
return hash;
}
export async function getRootStore(): Promise<string> {
const store = dir("config") + "/windmill/";
await ensureDir(store);
return store;
}
export async function getStore(baseUrl: string): Promise<string> {
const baseHash = Math.abs(hash_string(baseUrl)).toString(16);
const baseStore = (await getRootStore()) + baseHash + "/";
await ensureDir(baseStore);
return baseStore;
}