mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-08 05:39:13 +00:00
Keep sync state in memory, initialized to false in Desktop app
Prevent deadlock if desktop app killed in middle of syncing
This commit is contained in:
@@ -67,6 +67,7 @@ const schema = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const syncing = false;
|
||||||
var state = {}
|
var state = {}
|
||||||
const store = new Store({ schema });
|
const store = new Store({ schema });
|
||||||
|
|
||||||
@@ -111,12 +112,12 @@ function filenameToMimeType (filename) {
|
|||||||
|
|
||||||
function pushDataToKhoj (regenerate = false) {
|
function pushDataToKhoj (regenerate = false) {
|
||||||
// Don't sync if token or hostURL is not set or if already syncing
|
// Don't sync if token or hostURL is not set or if already syncing
|
||||||
if (store.get('khojToken') === '' || store.get('hostURL') === '' || store.get('syncing') === true) {
|
if (store.get('khojToken') === '' || store.get('hostURL') === '' || syncing === true) {
|
||||||
const win = BrowserWindow.getAllWindows()[0];
|
const win = BrowserWindow.getAllWindows()[0];
|
||||||
if (win) win.webContents.send('update-state', state);
|
if (win) win.webContents.send('update-state', state);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
store.set('syncing', true);
|
syncing = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
let filesToPush = [];
|
let filesToPush = [];
|
||||||
@@ -201,13 +202,13 @@ function pushDataToKhoj (regenerate = false) {
|
|||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
// Syncing complete
|
// Syncing complete
|
||||||
store.set('syncing', false);
|
syncing = false;
|
||||||
const win = BrowserWindow.getAllWindows()[0];
|
const win = BrowserWindow.getAllWindows()[0];
|
||||||
if (win) win.webContents.send('update-state', state);
|
if (win) win.webContents.send('update-state', state);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// Syncing complete
|
// Syncing complete
|
||||||
store.set('syncing', false);
|
syncing = false;
|
||||||
const win = BrowserWindow.getAllWindows()[0];
|
const win = BrowserWindow.getAllWindows()[0];
|
||||||
if (win) win.webContents.send('update-state', state);
|
if (win) win.webContents.send('update-state', state);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ api = APIRouter()
|
|||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def map_config_to_object(content_source: DbEntry.EntrySource):
|
def map_config_to_object(content_source: str):
|
||||||
if content_source == DbEntry.EntrySource.GITHUB:
|
if content_source == DbEntry.EntrySource.GITHUB:
|
||||||
return GithubConfig
|
return GithubConfig
|
||||||
if content_source == DbEntry.EntrySource.GITHUB:
|
if content_source == DbEntry.EntrySource.GITHUB:
|
||||||
|
|||||||
Reference in New Issue
Block a user