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

Support remote files over network drive, ftp, or ssh #67

Closed
ecker00 opened this issue Oct 2, 2018 · 9 comments
Closed

Support remote files over network drive, ftp, or ssh #67

ecker00 opened this issue Oct 2, 2018 · 9 comments

Comments

@ecker00
Copy link

ecker00 commented Oct 2, 2018

I'm using an SMB share to work in Windows from a virtual Linux VM. Turned on debugging and looking in the developer console and the log file to see why none of my time is being tracked (I've put in line breaks for readability).

VS Code dev console:

[Extension Host] [WakaTime] [DEBUG] Sending heartbeat:
C:\Users\myUser\.vscode\extensions\wakatime.vscode-wakatime-1.2.3\out\python\pythonw
C:\Users\myUser\.vscode\extensions\wakatime.vscode-wakatime-1.2.3\out\wakatime-master\wakatime\cli.py
--file \\192.168.0.10\myShare\myProject\myFile.sh
--plugin "vscode/1.27.2 vscode-wakatime/1.2.3"
--alternate-project myProject
--write
--config C:\Users\myUser\.wakatime.cfg
--logfile C:\Users\myUser\.wakatime.log

.wakatime.log:

{
"now": "2018/10/02 06:53:22 +0200",
"version": "10.3.0",
"plugin": "vscode/1.27.2 vscode-wakatime/1.2.3",
"time": 1538456002.735315,
"caller": "C:\\Users\\myUser\\.vscode\\extensions\\wakatime.vscode-wakatime-1.2.3\\out\\wakatime-master\\wakatime\\main.py",
"lineno": 51,
"is_write": true,
"file": "\\\\192.168.0.10\\myShare\\myProject\\myFile.sh",
"level": "DEBUG",
"message": "File does not exist; ignoring this heartbeat."
}

It seems that it detects that the file does not exist \\192.168.0.10\myShare\myProject\myFile.sh. But that path does work when entering it into Explorer, so I assume that Wakatime is not able to interpret a network path like Explorer does.

How can I get around this issue? Is there a way to ignore 'file does not exist' and track it anyway?

@ecker00
Copy link
Author

ecker00 commented Oct 2, 2018

For the record I tested making a symlink and open VS Code from that, but it still resolves to the true network path, even if Explorer operates from the symlinked path.

cd /Users/myUser
mklink /D myShare \\192.168.0.10\myShare

File does not exist; ignoring this heartbeat.

@alanhamlett
Copy link
Member

Related to wakatime/wakatime#72 and wakatime/wakatime-mode#27.

@alanhamlett alanhamlett changed the title Ignoring network files Support remote files over network drive, ftp, or ssh Oct 2, 2018
@alanhamlett
Copy link
Member

I assume that Wakatime is not able to interpret a network path like Explorer does.

That's right, WakaTime uses Python's os.path.isfile to check if the file exists. I think embedding pywin32 then using this is the solution: https://stackoverflow.com/a/45102663/1290627

@alanhamlett
Copy link
Member

Added network drive files support for Windows in v10.4.0. If you restart VS Code it will update wakatime-cli to the latest version. Let me know if it works!

@ecker00
Copy link
Author

ecker00 commented Oct 9, 2018

Thanks for attempting a fix. I gave it another shot and checked the logs. Seems the cli is at version 10.4.1 so it has updated, but I'm still getting the same error:

{
  "now": "2018/10/09 08:37:27 +0200",
  "version": "10.4.1",
  "plugin": "vscode/1.27.2 vscode-wakatime/1.2.3",
  "time": 1539067047.6750627,
  "caller": "C:\\Users\\myUser\\.vscode\\extensions\\wakatime.vscode-wakatime-1.2.3\\out\\wakatime-master\\wakatime\\main.py",
  "lineno": 52,
  "file": "\\\\192.168.172.128\\myShare\\myProj\\readme.md", 
  "level": "DEBUG",
  "message": "File does not exist; ignoring this heartbeat."
}

@glics
Copy link

glics commented May 18, 2020

Happening here as well. Windows 10 x64 1909, vscode 1.45.1, extension version 4.0.0.
Weird that it happens also when a remote folder is mapped as network drive 🤔
Here i am accessing the file via Z:\supersecretfolder\supersecretfile.php, where Z: is a mapping of the network folder \\192.168.0.222\htdocs. This is on SMB, in case it's not clear.

{
  "now": "2020/05/18 18:25:18 +0200",
  "version": "13.0.7",
  "plugin": "vscode/1.45.1 vscode-wakatime/4.0.0",
  "time": 1589819118.2597008,
  "caller": "wakatime\\main.py",
  "lineno": 68,
  "file": "\\\\192.168.0.222\\htdocs\\supersecretfolder\\supersecretfile.php",
  "level": "DEBUG",
  "message": "File does not exist; ignoring this heartbeat."
}

EDIT

Little update, apparently, this only happens when accessing paths via their ip addresses instead of their hostname.

To give you the best explaination I can offer, my previous log was on access to the following file paths (both leading to the same result in "file"):

Z:\supersecretfolder\supersecretfile.php
\\192.168.0.222\htdocs\supersecretfolder\supersecretfile.php
(where Z: is mapped as network drive for a shared folder on \\192.168.0.222\htdocs)

When instead i'm editing the same file from the following paths (again, both giving the same result):

Z:\supersecretfolder\supersecretfile.php
\\CFSERVER\htdocs\supersecretfolder\supersecretfile.php

Here, again, Z: is mapped as network folder for \\CFSERVER\htdocs, and CFSERVER is the hostname of the machine located at 192.168.0.222

{
  "now": "2020/05/18 18:41:06 +0200",
  "version": "13.0.7",
  "plugin": "vscode/1.45.1 vscode-wakatime/4.0.0",
  "time": 1589820066.6484404,
  "caller": "wakatime\\api.py",
  "lineno": 45,
  "is_write": true,
  "file": "\\\\CFSERVER\\htdocs\\supersecretfolder\\supersecretfile.php",
  "level": "DEBUG",
  "message": "Sending heartbeats to api at https://api.wakatime.com/api/v1/users/current/heartbeats.bulk"
}

I hope this helps in some way! If you need further clarifications or want me to test something else I'll do so as soon as I am able to.

@alanhamlett
Copy link
Member

Has this improved now that we're using the new Go wakatime-cli?

@ecker00
Copy link
Author

ecker00 commented Dec 26, 2021

I'm not affected by this issue anymore, so I can't confirm. But with the way VS code handles SSH connections these days it's not been a problem for me.

@alanhamlett
Copy link
Member

Related to wakatime/wakatime-cli#623, which added support for ssh:// and sftp:// remote files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants