[INFRA-192] fix: update file handling in airgapped mode to include app version in filenames #3439

This commit is contained in:
Nikhil
2025-06-18 15:35:55 +05:30
committed by GitHub
parent 6e79d533bf
commit cda00e2024
2 changed files with 7 additions and 4 deletions

View File

@@ -120,7 +120,7 @@ Downloads the workspace activation file from the server and returns the response
*/
func (a *AirgappedPrimeApi) SyncWorkspace(payload WorkspaceSyncPayload) (*WorkspaceActivationResponse, *APIError) {
// Step 1: Read the file from the local system
fileContent, err := os.ReadFile(payload.WorkspaceID + ".json")
fileContent, err := os.ReadFile(fmt.Sprintf("%s_%s.json", payload.WorkspaceID, a.AppVersion()))
if err != nil {
return nil, &APIError{
Error: fmt.Sprintf("Failed to read activation file: %v", err),
@@ -281,7 +281,10 @@ if the deactivation is successfull, it will proceed to delete the license from t
func (a *AirgappedPrimeApi) DeactivateLicense(payload LicenseDeactivatePayload) (*WorkspaceActivationResponse, *APIError) {
// Delete the license file from the local system
os.Remove(payload.WorkspaceID + ".json")
err := os.Remove(fmt.Sprintf("%s_%s.json", payload.WorkspaceID, a.AppVersion()))
if err != nil {
fmt.Println("Failed to delete license file", err)
}
response := GetMockWorkspaceActivationResponse(payload, true)
return response, nil

View File

@@ -75,8 +75,8 @@ func GetAirgappedActivationHandler(api prime_api.IPrimeMonitorApi, key string) f
})
}
// Create filename using workspaceId
filename := fmt.Sprintf("%s.json", workspaceId)
// Create filename using workspaceId and app version
filename := fmt.Sprintf("%s_%s.json", workspaceId, api.AppVersion())
// Write content to file
err = os.WriteFile(filename, content, 0644)