Skip to content

Commit 7e38510

Browse files
committed
Refactor import route to utilize organization storage rules and improve cloud sync logic
1 parent d0f5630 commit 7e38510

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

packages/insomnia/src/ui/routes/import.tsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type { ActionFunction } from 'react-router-dom';
55
import type { PostmanDataDumpRawData } from '../../common/import';
66
import { fetchImportContentFromURI, getFilesFromPostmanExportedDataDump, type ImportFileDetail, importResourcesToProject, importResourcesToWorkspace, scanResources, type ScanResult } from '../../common/import';
77
import * as models from '../../models';
8-
import { isRemoteProject, ORG_STORAGE_RULE } from '../../models/project';
8+
import { isRemoteProject } from '../../models/project';
99
import type { Workspace } from '../../models/workspace';
1010
import { initializeLocalBackendProjectAndMarkForSync, pushSnapshotOnInitialize } from '../../sync/vcs/initialize-backend-project';
1111
import { VCSInstance } from '../../sync/vcs/insomnia-sync';
@@ -149,7 +149,10 @@ async function syncNewWorkspaceIfNeeded(newWorkspace: Workspace) {
149149
const project = await models.project.getById(newWorkspace.parentId);
150150
invariant(project, 'Project not found');
151151
const userSession = await models.userSession.getOrCreate();
152-
if (userSession.id && isRemoteProject(project) && [ORG_STORAGE_RULE.CLOUD_ONLY, ORG_STORAGE_RULE.CLOUD_PLUS_LOCAL].includes(await fetchAndCacheOrganizationStorageRule(project.parentId))) {
152+
const storageRule = await fetchAndCacheOrganizationStorageRule(project.parentId);
153+
invariant(storageRule, 'Storage rule not found');
154+
155+
if (userSession.id && isRemoteProject(project) && storageRule.enableCloudSync) {
153156
// Create default env, cookie jar, and meta
154157
await models.environment.getOrCreateForParentId(newWorkspace._id);
155158
await models.cookieJar.getOrCreateForParentId(newWorkspace._id);

0 commit comments

Comments
 (0)