Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move .sagemaker-last-active-timestamp to /tmp/ #80

Merged
merged 1 commit into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading