Skip to content

Commit

Permalink
Merge pull request #80 from aws/move-idle-file
Browse files Browse the repository at this point in the history
Move .sagemaker-last-active-timestamp to /tmp/
  • Loading branch information
aws-asolidu authored Oct 16, 2024
2 parents 328915b + ec903b1 commit 2c2ebd5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,17 @@ export function deactivate() {

/**
* Initializes the file path where the idle timestamp will be stored.
* It sets the path to a hidden file in the user's home directory.
* It sets the path to a hidden file in the /tmp/ directory.
*/
function initializeIdleFilePath() {
const homeDirectory = process.env.HOME || process.env.USERPROFILE;
if (!homeDirectory) {
console.log(`${LOG_PREFIX} Unable to determine the home directory.`);
return;
}
idleFilePath = path.join(homeDirectory, ".sagemaker-last-active-timestamp");
const tmpDirectory = "/tmp/";
idleFilePath = path.join(tmpDirectory, ".sagemaker-last-active-timestamp");

// Set initial lastActivetimestamp
updateLastActivityTimestamp()
}


/**
* Registers event listeners to monitor user activity within the VSCode editor.
* It listens to document changes, editor focus changes, text selection changes, and terminal events.
Expand Down
8 changes: 2 additions & 6 deletions patched-vscode/src/vs/server/node/webClientServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -463,12 +463,8 @@ export class WebClientServer {
*/
private async _handleIdle(req: http.IncomingMessage, res: http.ServerResponse): Promise<void> {
try {
const homeDirectory = process.env.HOME || process.env.USERPROFILE;
if (!homeDirectory) {
throw new Error('Home directory not found');
}

const idleFilePath = path.join(homeDirectory, '.code-editor-last-active-timestamp');
const tmpDirectory = '/tmp/'
const idleFilePath = path.join(tmpDirectory, '.sagemaker-last-active-timestamp');
const data = await readFile(idleFilePath, 'utf8');

res.statusCode = 200;
Expand Down
22 changes: 7 additions & 15 deletions patches/sagemaker-idle-extension.patch
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ Index: sagemaker-code-editor/vscode/extensions/sagemaker-idle-extension/src/exte
===================================================================
--- /dev/null
+++ sagemaker-code-editor/vscode/extensions/sagemaker-idle-extension/src/extension.ts
@@ -0,0 +1,116 @@
@@ -0,0 +1,112 @@
+import * as vscode from "vscode";
+import * as fs from "fs";
+import * as path from "path";
Expand All @@ -171,15 +171,11 @@ Index: sagemaker-code-editor/vscode/extensions/sagemaker-idle-extension/src/exte
+
+/**
+ * Initializes the file path where the idle timestamp will be stored.
+ * It sets the path to a hidden file in the user's home directory.
+ * It sets the path to a hidden file in the /tmp/ directory.
+ */
+function initializeIdleFilePath() {
+ const homeDirectory = process.env.HOME || process.env.USERPROFILE;
+ if (!homeDirectory) {
+ console.log(`${LOG_PREFIX} Unable to determine the home directory.`);
+ return;
+ }
+ idleFilePath = path.join(homeDirectory, ".sagemaker-last-active-timestamp");
+ const tmpDirectory = "/tmp/";
+ idleFilePath = path.join(tmpDirectory, ".sagemaker-last-active-timestamp");
+
+ // Set initial lastActivetimestamp
+ updateLastActivityTimestamp()
Expand Down Expand Up @@ -327,7 +323,7 @@ Index: sagemaker-code-editor/vscode/src/vs/server/node/webClientServer.ts
if (pathname === this._callbackRoute) {
// callback support
return this._handleCallback(res);
@@ -451,6 +457,27 @@ export class WebClientServer {
@@ -451,6 +457,23 @@ export class WebClientServer {
});
return void res.end(data);
}
Expand All @@ -337,12 +333,8 @@ Index: sagemaker-code-editor/vscode/src/vs/server/node/webClientServer.ts
+ */
+ private async _handleIdle(req: http.IncomingMessage, res: http.ServerResponse): Promise<void> {
+ try {
+ const homeDirectory = process.env.HOME || process.env.USERPROFILE;
+ if (!homeDirectory) {
+ throw new Error('Home directory not found');
+ }
+
+ const idleFilePath = path.join(homeDirectory, '.sagemaker-last-active-timestamp');
+ const tmpDirectory = '/tmp/'
+ const idleFilePath = path.join(tmpDirectory, '.sagemaker-last-active-timestamp');
+ const data = await readFile(idleFilePath, 'utf8');
+
+ res.statusCode = 200;
Expand Down

0 comments on commit 2c2ebd5

Please sign in to comment.