mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
remove make-syncronous and file-type calls from migration (#844)
* remove make-syncronous and file-type calls from migration Signed-off-by: Sebastian Malton <smalton@mirantis.com> Co-authored-by: Sebastian Malton <smalton@mirantis.com>
This commit is contained in:
1 parent
763b07b7fc
commit
8d1f0efe80
5 files changed
+7
-39
No files matched your search
@@ -7,11 +7,6 @@ import { migration } from "../migration-wrapper";
|
||||
import fse from "fs-extra"
|
||||
import { ClusterModel, ClusterStore } from "../../common/cluster-store";
|
||||
import { loadConfig } from "../../common/kube-helpers";
|
||||
import makeSynchronous from "make-synchronous"
|
||||
|
||||
const AsyncFunction = Object.getPrototypeOf(async function () { return }).constructor;
|
||||
const getFileTypeFnString = `return require("file-type").fromBuffer(fileData)`;
|
||||
const getFileType = new AsyncFunction("fileData", getFileTypeFnString);
|
||||
|
||||
export default migration({
|
||||
version: "3.6.0-beta.1",
|
||||
@@ -48,13 +43,8 @@ export default migration({
|
||||
printLog(`migrating ${cluster.preferences.icon} for ${cluster.preferences.clusterName}`)
|
||||
const iconPath = cluster.preferences.icon.replace("store://", "")
|
||||
const fileData = fse.readFileSync(path.join(userDataPath, iconPath));
|
||||
const { mime = "" } = makeSynchronous(getFileType)(fileData);
|
||||
|
||||
if (!mime) {
|
||||
printLog(`mime type not detected for ${cluster.preferences.clusterName}'s icon: ${iconPath}`)
|
||||
}
|
||||
|
||||
cluster.preferences.icon = `data:${mime};base64, ${fileData.toString('base64')}`;
|
||||
cluster.preferences.icon = `data:;base64,${fileData.toString('base64')}`;
|
||||
} else {
|
||||
delete cluster.preferences?.icon;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user