mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-06 05:39:12 +00:00
Show relevant error msg in desktop app, e.g when can't connect to server
This commit is contained in:
@@ -114,8 +114,8 @@ function processDirectory(filesToPush, folder) {
|
|||||||
const files = fs.readdirSync(folder.path, { withFileTypes: true, recursive: true });
|
const files = fs.readdirSync(folder.path, { withFileTypes: true, recursive: true });
|
||||||
|
|
||||||
for (const file of files) {
|
for (const file of files) {
|
||||||
console.log(file);
|
|
||||||
if (file.isFile() && validFileTypes.includes(file.name.split('.').pop())) {
|
if (file.isFile() && validFileTypes.includes(file.name.split('.').pop())) {
|
||||||
|
console.log(`Add ${file.name} in ${folder.path} for indexing`);
|
||||||
filesToPush.push(path.join(folder.path, file.name));
|
filesToPush.push(path.join(folder.path, file.name));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,17 +214,20 @@ function pushDataToKhoj (regenerate = false) {
|
|||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
state["completed"] = false;
|
state["completed"] = false;
|
||||||
if (error.response.status === 429) {
|
if (error?.response?.status === 429 && (win = BrowserWindow.getAllWindows()[0])) {
|
||||||
win = BrowserWindow.getAllWindows()[0]
|
state["error"] = `Looks like you're out of space to sync your files. <a href="https://app.khoj.dev/config">Upgrade your plan</a> to unlock more space.`;
|
||||||
if (win) win.webContents.send('needsSubscription', true);
|
} else if (error?.code === 'ECONNREFUSED') {
|
||||||
if (win) win.webContents.send('update-state', state);
|
state["error"] = `Could not connect to Khoj server. Ensure you can connect to it at ${error.address}:${error.port}.`;
|
||||||
|
} else {
|
||||||
|
state["error"] = `Sync was unsuccessful at ${currentTime.toLocaleTimeString()}. Contact team@khoj.dev to report this issue.`;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
// Syncing complete
|
// Syncing complete
|
||||||
syncing = false;
|
syncing = false;
|
||||||
const win = BrowserWindow.getAllWindows()[0];
|
if (win = BrowserWindow.getAllWindows()[0]) {
|
||||||
if (win) win.webContents.send('update-state', state);
|
win.webContents.send('update-state', state);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ window.updateStateAPI.onUpdateState((event, state) => {
|
|||||||
nextSyncTime = new Date();
|
nextSyncTime = new Date();
|
||||||
nextSyncTime.setMinutes(Math.ceil((nextSyncTime.getMinutes() + 1) / 10) * 10);
|
nextSyncTime.setMinutes(Math.ceil((nextSyncTime.getMinutes() + 1) / 10) * 10);
|
||||||
if (state.completed == false) {
|
if (state.completed == false) {
|
||||||
syncStatusElement.innerHTML = `Sync was unsuccessful at ${currentTime.toLocaleTimeString()}. Contact team@khoj.dev to report this issue.`;
|
if (state.error) syncStatusElement.innerHTML = state.error;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const options = { hour: '2-digit', minute: '2-digit' };
|
const options = { hour: '2-digit', minute: '2-digit' };
|
||||||
|
|||||||
Reference in New Issue
Block a user