mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-30 03:24:01 +00:00
refresh public cloud files only on session start
This commit is contained in:
@@ -29,8 +29,8 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
refreshPublicFiles_meta: true,
|
refreshPublicFiles_meta: true,
|
||||||
async refreshPublicFiles() {
|
async refreshPublicFiles({ isRefresh }) {
|
||||||
await refreshPublicFiles();
|
await refreshPublicFiles(isRefresh);
|
||||||
return {
|
return {
|
||||||
status: 'ok',
|
status: 'ok',
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -143,9 +143,7 @@ async function getCloudSigninHeaders(holder = null) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
let cloudFilesWereUpdated = false;
|
async function updateCloudFiles(isRefresh) {
|
||||||
|
|
||||||
async function updateCloudFiles() {
|
|
||||||
let lastCloudFilesTags;
|
let lastCloudFilesTags;
|
||||||
try {
|
try {
|
||||||
lastCloudFilesTags = await fs.readFile(path.join(datadir(), 'cloud-files-tags.txt'), 'utf-8');
|
lastCloudFilesTags = await fs.readFile(path.join(datadir(), 'cloud-files-tags.txt'), 'utf-8');
|
||||||
@@ -163,7 +161,7 @@ async function updateCloudFiles() {
|
|||||||
|
|
||||||
const resp = await axios.default.get(
|
const resp = await axios.default.get(
|
||||||
`${DBGATE_CLOUD_URL}/public-cloud-updates?lastCheckedTm=${lastCheckedTm}&tags=${tags}&isRefresh=${
|
`${DBGATE_CLOUD_URL}/public-cloud-updates?lastCheckedTm=${lastCheckedTm}&tags=${tags}&isRefresh=${
|
||||||
cloudFilesWereUpdated ? 1 : 0
|
isRefresh ? 1 : 0
|
||||||
}`,
|
}`,
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
@@ -172,7 +170,6 @@ async function updateCloudFiles() {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
cloudFilesWereUpdated = true;
|
|
||||||
|
|
||||||
logger.info(`Downloaded ${resp.data.length} cloud files`);
|
logger.info(`Downloaded ${resp.data.length} cloud files`);
|
||||||
|
|
||||||
@@ -194,7 +191,7 @@ async function updateCloudFiles() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function startCloudFiles() {
|
async function startCloudFiles() {
|
||||||
refreshPublicFiles();
|
loadCloudFiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getPublicCloudFiles() {
|
async function getPublicCloudFiles() {
|
||||||
@@ -213,12 +210,12 @@ async function getPublicFileData(path) {
|
|||||||
return resp.data;
|
return resp.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function refreshPublicFiles() {
|
async function refreshPublicFiles(isRefresh) {
|
||||||
if (!cloudFiles) {
|
if (!cloudFiles) {
|
||||||
await loadCloudFiles();
|
await loadCloudFiles();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await updateCloudFiles();
|
await updateCloudFiles(isRefresh);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.error(extractErrorLogData(err), 'Error updating cloud files');
|
logger.error(extractErrorLogData(err), 'Error updating cloud files');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,12 @@
|
|||||||
// import { shouldWaitForElectronInitialize } from './utility/getElectron';
|
// import { shouldWaitForElectronInitialize } from './utility/getElectron';
|
||||||
import { subscribeConnectionPingers } from './utility/connectionsPinger';
|
import { subscribeConnectionPingers } from './utility/connectionsPinger';
|
||||||
import { subscribePermissionCompiler } from './utility/hasPermission';
|
import { subscribePermissionCompiler } from './utility/hasPermission';
|
||||||
import { apiCall, installNewCloudTokenListener, installNewVolatileConnectionListener } from './utility/api';
|
import {
|
||||||
|
apiCall,
|
||||||
|
installNewCloudTokenListener,
|
||||||
|
installNewVolatileConnectionListener,
|
||||||
|
refreshPublicCloudFiles,
|
||||||
|
} from './utility/api';
|
||||||
import { getConfig, getSettings, getUsedApps } from './utility/metadataLoaders';
|
import { getConfig, getSettings, getUsedApps } from './utility/metadataLoaders';
|
||||||
import AppTitleProvider from './utility/AppTitleProvider.svelte';
|
import AppTitleProvider from './utility/AppTitleProvider.svelte';
|
||||||
import getElectron from './utility/getElectron';
|
import getElectron from './utility/getElectron';
|
||||||
@@ -55,6 +60,8 @@
|
|||||||
initializeAppUpdates();
|
initializeAppUpdates();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
refreshPublicCloudFiles();
|
||||||
|
|
||||||
loadedApi = loadedApiValue;
|
loadedApi = loadedApiValue;
|
||||||
|
|
||||||
if (!loadedApi) {
|
if (!loadedApi) {
|
||||||
|
|||||||
@@ -300,6 +300,15 @@ export function getAuthCategory(config) {
|
|||||||
return 'token';
|
return 'token';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function refreshPublicCloudFiles() {
|
||||||
|
if (sessionStorage.getItem('publicCloudFilesLoaded')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
apiCall('cloud/refresh-public-files');
|
||||||
|
sessionStorage.setItem('publicCloudFilesLoaded', 'true');
|
||||||
|
}
|
||||||
|
|
||||||
function enableApiLog() {
|
function enableApiLog() {
|
||||||
apiLogging = true;
|
apiLogging = true;
|
||||||
console.log('API loggin enabled');
|
console.log('API loggin enabled');
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
const publicFiles = usePublicCloudFiles();
|
const publicFiles = usePublicCloudFiles();
|
||||||
|
|
||||||
async function handleRefreshPublic() {
|
async function handleRefreshPublic() {
|
||||||
await apiCall('cloud/refresh-public-files');
|
await apiCall('cloud/refresh-public-files?isRefresh=1');
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user