mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
correctly handle the previous icon fields value
Signed-off-by: Sebastian Malton <smalton@mirantis.com>
This commit is contained in:
parent
bc9476e67f
commit
35b42de27e
@ -13,7 +13,8 @@ import makeSynchronous from "make-synchronous"
|
|||||||
export default migration({
|
export default migration({
|
||||||
version: "3.6.0-beta.1",
|
version: "3.6.0-beta.1",
|
||||||
run(store, printLog) {
|
run(store, printLog) {
|
||||||
const kubeConfigBase = path.join((app || remote.app).getPath("userData"), "kubeconfigs")
|
const userDataPath = (app || remote.app).getPath("userData")
|
||||||
|
const kubeConfigBase = path.join(userDataPath, "kubeconfigs")
|
||||||
const storedClusters: ClusterModel[] = store.get("clusters") || [];
|
const storedClusters: ClusterModel[] = store.get("clusters") || [];
|
||||||
|
|
||||||
if (!storedClusters.length) return;
|
if (!storedClusters.length) return;
|
||||||
@ -41,11 +42,13 @@ export default migration({
|
|||||||
*/
|
*/
|
||||||
try {
|
try {
|
||||||
if (cluster.preferences.icon) {
|
if (cluster.preferences.icon) {
|
||||||
const fileData = fse.readFileSync(cluster.preferences.icon);
|
printLog(`migrating ${cluster.preferences.icon} for ${cluster.preferences.clusterName}`)
|
||||||
const { mime } = makeSynchronous(() => fileType.fromBuffer(fileData))();
|
const iconPath = cluster.preferences.icon.replace("store://", "")
|
||||||
|
const fileData = fse.readFileSync(path.join(userDataPath, iconPath));
|
||||||
|
const { mime = "" } = makeSynchronous(() => fileType.fromBuffer(fileData))();
|
||||||
|
|
||||||
if (!mime) {
|
if (!mime) {
|
||||||
throw "unknown icon file type, deleting...";
|
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:${mime};base64, ${fileData.toString('base64')}`;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user