From 5566e6c7d437a951ff30d7efd9f20e83873e63ea Mon Sep 17 00:00:00 2001 From: Brett Saviano Date: Mon, 25 Mar 2024 11:46:41 -0400 Subject: [PATCH] Update timestamp when modifying a project (#1337) --- src/commands/project.ts | 21 +++++++++++++++++++-- src/explorer/explorer.ts | 6 ++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/commands/project.ts b/src/commands/project.ts index 07d51f3e..8211f48e 100644 --- a/src/commands/project.ts +++ b/src/commands/project.ts @@ -126,7 +126,10 @@ export async function createProject(node: NodeBase | undefined, api?: AtelierAPI if (desc !== undefined) { try { // Create the project - await api.actionQuery("INSERT INTO %Studio.Project (Name,Description) VALUES (?,?)", [name, desc]); + await api.actionQuery("INSERT INTO %Studio.Project (Name,Description,LastModified) VALUES (?,?,NOW())", [ + name, + desc, + ]); } catch (error) { let message = `Failed to create project '${name}'.`; if (error && error.errorText && error.errorText !== "") { @@ -910,6 +913,12 @@ export async function modifyProject( [] ); } + if (add.length || remove.length) { + // Update the project's timestamp + await api.actionQuery("UPDATE %Studio.Project SET LastModified = NOW() WHERE Name = ?", [project]).catch(() => { + // Swallow error because VS Code doesn't care about the timestamp + }); + } } catch (error) { let message = `Failed to modify project '${project}'.`; if (error && error.errorText && error.errorText !== "") { @@ -1118,6 +1127,11 @@ export async function addIsfsFileToProject( .join(" UNION ")})`, [] ); + + // Update the project's timestamp + await api.actionQuery("UPDATE %Studio.Project SET LastModified = NOW() WHERE Name = ?", [project]).catch(() => { + // Swallow error because VS Code doesn't care about the timestamp + }); } } catch (error) { let message = `Failed to modify project '${project}'.`; @@ -1223,7 +1237,10 @@ export async function modifyProjectMetadata(nodeOrUri: NodeBase | vscode.Uri | u } // Modify the project - await api.actionQuery("UPDATE %Studio.Project SET Description = ? WHERE Name = ?", [newDesc, project]); + await api.actionQuery("UPDATE %Studio.Project SET Description = ?, LastModified = NOW() WHERE Name = ?", [ + newDesc, + project, + ]); // Refesh the explorer projectsExplorerProvider.refresh(); diff --git a/src/explorer/explorer.ts b/src/explorer/explorer.ts index 2437b691..6835d296 100644 --- a/src/explorer/explorer.ts +++ b/src/explorer/explorer.ts @@ -123,6 +123,12 @@ export function registerExplorerOpen(): vscode.Disposable { `${prjFileName}${prjType}`.toLowerCase(), ]); } + // Update the project's timestamp + await api + .actionQuery("UPDATE %Studio.Project SET LastModified = NOW() WHERE Name = ?", [project]) + .catch(() => { + // Swallow error because VS Code doesn't care about the timestamp + }); } catch (error) { let message = `Failed to remove '${fullName}' from project '${project}'.`; if (error && error.errorText && error.errorText !== "") {