mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-02 21:19: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 });
|
||||
|
||||
for (const file of files) {
|
||||
console.log(file);
|
||||
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));
|
||||
}
|
||||
|
||||
@@ -214,17 +214,20 @@ function pushDataToKhoj (regenerate = false) {
|
||||
.catch(error => {
|
||||
console.error(error);
|
||||
state["completed"] = false;
|
||||
if (error.response.status === 429) {
|
||||
win = BrowserWindow.getAllWindows()[0]
|
||||
if (win) win.webContents.send('needsSubscription', true);
|
||||
if (win) win.webContents.send('update-state', state);
|
||||
if (error?.response?.status === 429 && (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.`;
|
||||
} else if (error?.code === 'ECONNREFUSED') {
|
||||
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(() => {
|
||||
// Syncing complete
|
||||
syncing = false;
|
||||
const win = BrowserWindow.getAllWindows()[0];
|
||||
if (win) win.webContents.send('update-state', state);
|
||||
if (win = BrowserWindow.getAllWindows()[0]) {
|
||||
win.webContents.send('update-state', state);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -158,7 +158,7 @@ window.updateStateAPI.onUpdateState((event, state) => {
|
||||
nextSyncTime = new Date();
|
||||
nextSyncTime.setMinutes(Math.ceil((nextSyncTime.getMinutes() + 1) / 10) * 10);
|
||||
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;
|
||||
}
|
||||
const options = { hour: '2-digit', minute: '2-digit' };
|
||||
|
||||
Reference in New Issue
Block a user