Skip to content

Commit b8c7f35

Browse files
authored
Merge pull request #83 from aws-asolidu/1.3-move-tmp
Move .sagemaker-last-active-timestamp to /tmp/
2 parents 3204978 + c1eed2e commit b8c7f35

File tree

3 files changed

+13
-28
lines changed

3 files changed

+13
-28
lines changed

patched-vscode/extensions/sagemaker-idle-extension/src/extension.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,17 @@ export function deactivate() {
2121

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

3430
// Set initial lastActivetimestamp
3531
updateLastActivityTimestamp()
3632
}
3733

34+
3835
/**
3936
* Registers event listeners to monitor user activity within the VSCode editor.
4037
* It listens to document changes, editor focus changes, text selection changes, and terminal events.

patched-vscode/src/vs/server/node/webClientServer.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -463,12 +463,8 @@ export class WebClientServer {
463463
*/
464464
private async _handleIdle(req: http.IncomingMessage, res: http.ServerResponse): Promise<void> {
465465
try {
466-
const homeDirectory = process.env.HOME || process.env.USERPROFILE;
467-
if (!homeDirectory) {
468-
throw new Error('Home directory not found');
469-
}
470-
471-
const idleFilePath = path.join(homeDirectory, '.code-editor-last-active-timestamp');
466+
const tmpDirectory = '/tmp/'
467+
const idleFilePath = path.join(tmpDirectory, '.sagemaker-last-active-timestamp');
472468
const data = await readFile(idleFilePath, 'utf8');
473469

474470
res.statusCode = 200;

patches/sagemaker-idle-extension.patch

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ Index: sagemaker-code-editor/vscode/extensions/sagemaker-idle-extension/src/exte
147147
===================================================================
148148
--- /dev/null
149149
+++ sagemaker-code-editor/vscode/extensions/sagemaker-idle-extension/src/extension.ts
150-
@@ -0,0 +1,116 @@
150+
@@ -0,0 +1,112 @@
151151
+import * as vscode from "vscode";
152152
+import * as fs from "fs";
153153
+import * as path from "path";
@@ -171,15 +171,11 @@ Index: sagemaker-code-editor/vscode/extensions/sagemaker-idle-extension/src/exte
171171
+
172172
+/**
173173
+ * Initializes the file path where the idle timestamp will be stored.
174-
+ * It sets the path to a hidden file in the user's home directory.
174+
+ * It sets the path to a hidden file in the /tmp/ directory.
175175
+ */
176176
+function initializeIdleFilePath() {
177-
+ const homeDirectory = process.env.HOME || process.env.USERPROFILE;
178-
+ if (!homeDirectory) {
179-
+ console.log(`${LOG_PREFIX} Unable to determine the home directory.`);
180-
+ return;
181-
+ }
182-
+ idleFilePath = path.join(homeDirectory, ".sagemaker-last-active-timestamp");
177+
+ const tmpDirectory = "/tmp/";
178+
+ idleFilePath = path.join(tmpDirectory, ".sagemaker-last-active-timestamp");
183179
+
184180
+ // Set initial lastActivetimestamp
185181
+ updateLastActivityTimestamp()
@@ -327,7 +323,7 @@ Index: sagemaker-code-editor/vscode/src/vs/server/node/webClientServer.ts
327323
if (pathname === this._callbackRoute) {
328324
// callback support
329325
return this._handleCallback(res);
330-
@@ -451,6 +457,27 @@ export class WebClientServer {
326+
@@ -451,6 +457,23 @@ export class WebClientServer {
331327
});
332328
return void res.end(data);
333329
}
@@ -337,12 +333,8 @@ Index: sagemaker-code-editor/vscode/src/vs/server/node/webClientServer.ts
337333
+ */
338334
+ private async _handleIdle(req: http.IncomingMessage, res: http.ServerResponse): Promise<void> {
339335
+ try {
340-
+ const homeDirectory = process.env.HOME || process.env.USERPROFILE;
341-
+ if (!homeDirectory) {
342-
+ throw new Error('Home directory not found');
343-
+ }
344-
+
345-
+ const idleFilePath = path.join(homeDirectory, '.sagemaker-last-active-timestamp');
336+
+ const tmpDirectory = '/tmp/'
337+
+ const idleFilePath = path.join(tmpDirectory, '.sagemaker-last-active-timestamp');
346338
+ const data = await readFile(idleFilePath, 'utf8');
347339
+
348340
+ res.statusCode = 200;

0 commit comments

Comments
 (0)