diff --git a/src/apps/user/appstore/runtime.ts b/src/apps/user/appstore/runtime.ts
index 30c8a2bf..a936eedd 100755
--- a/src/apps/user/appstore/runtime.ts
+++ b/src/apps/user/appstore/runtime.ts
@@ -331,19 +331,20 @@ export class AppStoreRuntime extends AppProcess {
this.pid
);
- const result = await this.distrib.publishing_updateStoreItemFromPath(pkg._id, path, (progress) => {
+ const updateResult = await this.distrib.publishing_updateStoreItemFromPath(pkg._id, path, (progress) => {
prog.show();
prog.setMax(progress.max + 1);
prog.setDone(progress.value);
if (progress.what) prog.updSub(progress.what);
});
- if (!result) {
+ prog.stop();
+
+ if (!updateResult.success) {
MessageBox(
{
title: "Failed to update store item",
- message:
- "The server didn't accept your update package. Maybe its format is incorrect, the app ID differs, or the version isn't increased. Please check the package and try again.",
+ message: `The server didn't accept your update package. Maybe its format is incorrect, the app ID differs, or the version isn't increased. Please check the package and try again.
Details: ${updateResult.errorMessage ?? "Unknown error"}`,
buttons: [{ caption: "Okay", action: () => {}, suggested: true }],
image: "ErrorIcon",
sound: "arcos.dialog.error",
@@ -356,8 +357,6 @@ export class AppStoreRuntime extends AppProcess {
}
await this.switchPage("manageStoreItem", { id: pkg._id }, true);
-
- prog.stop();
}
readmeFallback(pkg: StoreItem): string {
diff --git a/src/css/apps/core/loginapp.css b/src/css/apps/core/loginapp.css
index c3c9096e..b9f28b6f 100755
--- a/src/css/apps/core/loginapp.css
+++ b/src/css/apps/core/loginapp.css
@@ -168,7 +168,8 @@ div.window#loginApp > div.body div.login-form button.continue:active span.lucide
}
div.window#loginApp > div.body p.error-message {
font-size: 16px;
- max-width: 600px;
+ max-width: 550px;
+ width: fit-content;
text-align: center;
}
diff --git a/src/interfaces/services/DistribSvc.ts b/src/interfaces/services/DistribSvc.ts
index c720057d..be329230 100644
--- a/src/interfaces/services/DistribSvc.ts
+++ b/src/interfaces/services/DistribSvc.ts
@@ -1,7 +1,9 @@
import type { Constructs } from "$interfaces/common";
import type { IInstallerProcessBase } from "$interfaces/distrib";
+import type { ICommandResult } from "$interfaces/result";
import type { IBaseService } from "$interfaces/service";
import type { FilesystemProgressCallback } from "$types/fs";
+import type { UpdateWriteOpResult } from "$types/mongo";
import type { ArcPackage, PartialStoreItem, StoreItem, UpdateInfo } from "$types/package";
import type { UserPreferencesStore } from "$types/user";
import type JSZip from "jszip";
@@ -60,5 +62,5 @@ export interface IDistributionServiceProcess extends IBaseService {
itemId: string,
updatePath: string,
onProgress?: FilesystemProgressCallback
- ): Promise;
-}
\ No newline at end of file
+ ): Promise>;
+}
diff --git a/src/ts/daemon/contexts/account.ts b/src/ts/daemon/contexts/account.ts
index 38ff6070..a5d867a8 100644
--- a/src/ts/daemon/contexts/account.ts
+++ b/src/ts/daemon/contexts/account.ts
@@ -3,17 +3,15 @@ import type { IUserDaemon } from "$interfaces/daemon";
import DeleteUser from "$lib/Daemon/DeleteUser.svelte";
import { Env, Server, SysDispatch } from "$ts/env";
import { Backend } from "$ts/kernel/mods/server/axios";
+import { CommandResult } from "$ts/result";
import { authcode } from "$ts/util";
import { MessageBox } from "$ts/util/dialog";
import { toForm } from "$ts/util/form";
import { ElevationLevel } from "$types/elevation";
-import { LogLevel } from "$types/logging";
import type { PublicUserInfo, UserInfo } from "$types/user";
import Cookies from "js-cookie";
import { Daemon } from "..";
import { UserContext } from "../context";
-import { CommandResult } from "$ts/result";
-import { AxiosError } from "axios";
export class AccountUserContext extends UserContext implements IAccountUserContext {
constructor(id: string, daemon: IUserDaemon) {
@@ -69,10 +67,7 @@ export class AccountUserContext extends UserContext implements IAccountUserConte
return CommandResult.Ok(response.data as UserInfo);
} catch (e) {
await Daemon!.killSelf();
-
- const error = (e instanceof AxiosError ? e?.response?.data?.e : `${e}`) || `Unknown error`;
-
- return CommandResult.Error(error);
+ return CommandResult.AxiosError(e, "Unknown error while obtaining user information. Please try again.");
}
}
diff --git a/src/ts/kernel/mods/fs/drives/src.ts b/src/ts/kernel/mods/fs/drives/src.ts
index 2d3e7507..958f5ac9 100644
--- a/src/ts/kernel/mods/fs/drives/src.ts
+++ b/src/ts/kernel/mods/fs/drives/src.ts
@@ -58,7 +58,7 @@ export class SourceFilesystemDrive extends FilesystemDrive {
return CommandResult.Ok(response.data);
} catch (e) {
- return CommandResult.Error(`Failed to read file: ${e}`);
+ return CommandResult.AxiosError(e);
}
}
@@ -69,7 +69,7 @@ export class SourceFilesystemDrive extends FilesystemDrive {
return CommandResult.Ok(response.data);
} catch (e) {
- return CommandResult.Error(`Failed to read folder: ${e}`);
+ return CommandResult.AxiosError(e);
}
}
diff --git a/src/ts/kernel/mods/fs/proxies/src.ts b/src/ts/kernel/mods/fs/proxies/src.ts
index ea385049..98862c5d 100644
--- a/src/ts/kernel/mods/fs/proxies/src.ts
+++ b/src/ts/kernel/mods/fs/proxies/src.ts
@@ -30,7 +30,7 @@ export class SourceFilesystemProxy extends FilesystemProxy {
return CommandResult.Ok(response.data);
} catch (e) {
- return CommandResult.Error(`Failed to read file: ${e}`);
+ return CommandResult.AxiosError(e);
}
}
@@ -41,7 +41,7 @@ export class SourceFilesystemProxy extends FilesystemProxy {
return CommandResult.Ok(response.data);
} catch (e) {
- return CommandResult.Error(`Failed to read folder: ${e}`);
+ return CommandResult.AxiosError(e);
}
}
diff --git a/src/ts/result.ts b/src/ts/result.ts
index 28af8395..06697407 100644
--- a/src/ts/result.ts
+++ b/src/ts/result.ts
@@ -1,5 +1,6 @@
import type { ICommandResult } from "$interfaces/result";
import { DefaultCommandResultOptions, type CommandResultOptions } from "$types/result";
+import { AxiosError } from "axios";
import { Log } from "./logging";
export class CommandResult implements ICommandResult {
@@ -27,4 +28,8 @@ export class CommandResult implements ICommandResult {
return new this(undefined, { errorMessage });
}
+
+ static AxiosError(e: unknown, fallback: string = "Unknown error") {
+ return new this(undefined, { errorMessage: (e instanceof AxiosError ? e.response?.data?.e : `${e || ""}`) || fallback });
+ }
}
diff --git a/src/ts/servicehost/services/DistribSvc/index.ts b/src/ts/servicehost/services/DistribSvc/index.ts
index 6e61e007..6e293092 100644
--- a/src/ts/servicehost/services/DistribSvc/index.ts
+++ b/src/ts/servicehost/services/DistribSvc/index.ts
@@ -3,6 +3,7 @@ import type { IDistributionServiceProcess } from "$interfaces/services/DistribSv
import { Daemon } from "$ts/daemon";
import { Fs, Stack } from "$ts/env";
import { Backend } from "$ts/kernel/mods/server/axios";
+import { CommandResult } from "$ts/result";
import type { ServiceHost } from "$ts/servicehost";
import { BaseService } from "$ts/servicehost/base";
import { UserPaths } from "$ts/user/store";
@@ -11,6 +12,7 @@ import { join } from "$ts/util/fs";
import { tryJsonParse } from "$ts/util/json";
import { compareVersion } from "$ts/util/version";
import type { FilesystemProgressCallback } from "$types/fs";
+import type { UpdateWriteOpResult } from "$types/mongo";
import type { ArcPackage, PartialStoreItem, StoreItem, UpdateInfo } from "$types/package";
import type { Service } from "$types/service";
import type { UserPreferencesStore } from "$types/user";
@@ -670,17 +672,21 @@ export class DistributionServiceProcess extends BaseService implements IDistribu
}
}
- async publishing_updateStoreItemFromPath(itemId: string, updatePath: string, onProgress?: FilesystemProgressCallback) {
+ async publishing_updateStoreItemFromPath(
+ itemId: string,
+ updatePath: string,
+ onProgress?: FilesystemProgressCallback
+ ): Promise> {
this.Log(`publishing_updateStoreItemFromPath: ${itemId} -> ${updatePath}`);
- if (this.checkBusy("publishing_updateStoreItemFromPath")) return false;
+ if (this.checkBusy("publishing_updateStoreItemFromPath")) return CommandResult.Error("Distribution Service is busy");
try {
const contents = await Fs.readFile(updatePath, (p) => {
onProgress?.({ ...p, what: "Loading update package" });
});
- if (!contents) return false;
+ if (!contents) return CommandResult.Error("Failed to read the update file");
const newData = arrayBufferToBlob(contents);
const response = await Backend.patch(`/store/publish/${itemId}`, newData, {
@@ -695,9 +701,11 @@ export class DistributionServiceProcess extends BaseService implements IDistribu
},
});
- return response.status === 200;
- } catch {
- return false;
+ if (response.status !== 200) return CommandResult.AxiosError(response.data?.e ?? "Unknown error");
+
+ return CommandResult.Ok(response.data);
+ } catch (e) {
+ return CommandResult.AxiosError(e);
}
}
diff --git a/src/ts/user/auth.ts b/src/ts/user/auth.ts
index 57e96a50..5597b2b3 100644
--- a/src/ts/user/auth.ts
+++ b/src/ts/user/auth.ts
@@ -22,11 +22,12 @@ export async function LoginUser(identity: string, password: string): Promise