thesamim / TickTickSync

GNU General Public License v3.0
98 stars 2 forks source link

An error will occur when the sync button is clicked or during automatic synchronization! #86

Closed IMXeno123 closed 2 months ago

IMXeno123 commented 3 months ago

Describe the bug An error will occur when the sync button is clicked or during automatic synchronization! But the error doesn't affect synchronization, at least I didn't find it did. To Reproduce Steps to reproduce the behavior:

  1. Click the TickTickSync button or during automatic synchronization
  2. Console prompt an error

Expected behavior The console should not display any error messages.

Log

plugin:tickticksync:23406 An error occurred: Error: EISDIR: illegal operation on a directory, read
scheduledSynchronization @ plugin:tickticksync:23406
await in scheduledSynchronization (async)
eval @ plugin:tickticksync:22930

Screenshots Screenshot 2024-03-21 095854

Desktop (please complete the following information):

thesamim commented 3 months ago

Just saw this as I was releasing 1.0.21.

Please repeat the test with 1.0.21 and let me know what happens. I don't think it's fixed, but getting the updated line numbers would help.

Thanks.

IMXeno123 commented 3 months ago

Just saw this as I was releasing 1.0.21.

Please repeat the test with 1.0.21 and let me know what happens. I don't think it's fixed, but getting the updated line numbers would help.

Thanks.

Hello, I have just tested the new version 1.0.21 and there are more errors...it seems to be getting worse!


Log

plugin:tickticksync:23358 TickTick scheduled synchronization task started at 3/21/2024, 11:20:33 AM
plugin:tickticksync:22747 We have:  37  tasks on https://api.ticktick.com/api/v2
plugin:tickticksync:22748 There are:  36  tasks in Cache.
plugin:tickticksync:21600 Folder /01_Documents/Tasks does not exit. It will be created
getOrCreateDefaultFile @ plugin:tickticksync:21600
addTasksToFile @ plugin:tickticksync:21581
await in addTasksToFile (async)
syncTickTickToObsidian @ plugin:tickticksync:22763
await in syncTickTickToObsidian (async)
scheduledSynchronization @ plugin:tickticksync:23365
await in scheduledSynchronization (async)
eval @ plugin:tickticksync:22987
plugin:tickticksync:21618 Error on create file:  Error: Folder already exists.
    at t.<anonymous> (app.js:1:737164)
    at app.js:1:237056
    at Object.next (app.js:1:237161)
    at a (app.js:1:235879)
getOrCreateDefaultFile @ plugin:tickticksync:21618
await in getOrCreateDefaultFile (async)
addTasksToFile @ plugin:tickticksync:21581
await in addTasksToFile (async)
syncTickTickToObsidian @ plugin:tickticksync:22763
await in syncTickTickToObsidian (async)
scheduledSynchronization @ plugin:tickticksync:23365
await in scheduledSynchronization (async)
eval @ plugin:tickticksync:22987
plugin:tickticksync:22832 An error occurred while synchronizing: Error: Error: Folder already exists.
    at FileOperation.getOrCreateDefaultFile (plugin:tickticksync:21619:13)
    at async FileOperation.addTasksToFile (plugin:tickticksync:21581:18)
    at async SyncMan.syncTickTickToObsidian (plugin:tickticksync:22763:22)
    at async TickTickSync.scheduledSynchronization (plugin:tickticksync:23365:24)
    at async HTMLDivElement.eval (plugin:tickticksync:22987:9)
syncTickTickToObsidian @ plugin:tickticksync:22832
await in syncTickTickToObsidian (async)
scheduledSynchronization @ plugin:tickticksync:23365
await in scheduledSynchronization (async)
eval @ plugin:tickticksync:22987
plugin:tickticksync:23463 An error occurred: Error: EISDIR: illegal operation on a directory, read
scheduledSynchronization @ plugin:tickticksync:23463
await in scheduledSynchronization (async)
eval @ plugin:tickticksync:22987
plugin:tickticksync:23467 TickTick scheduled synchronization task completed at 3/21/2024, 11:20:35 AM
IMXeno123 commented 3 months ago

After changing the default folder /01_Documents/Tasks to 01_Documents/Tasks, these errors have been reduced.


Log

plugin:tickticksync:23358 TickTick scheduled synchronization task started at 3/21/2024, 11:41:56 AM
plugin:tickticksync:22747 We have:  38  tasks on https://api.ticktick.com/api/v2
plugin:tickticksync:22748 There are:  38  tasks in Cache.
plugin:tickticksync:22828 No synchronization changes.
plugin:tickticksync:23463 An error occurred: Error: EISDIR: illegal operation on a directory, read
scheduledSynchronization @ plugin:tickticksync:23463
await in scheduledSynchronization (async)
eval @ plugin:tickticksync:22987
plugin:tickticksync:23467 TickTick scheduled synchronization task completed at 3/21/2024, 11:41:57 AM
plugin:tickticksync:23358 TickTick scheduled synchronization task started at 3/21/2024, 11:43:23 AM
plugin:tickticksync:22747 We have:  38  tasks on https://api.ticktick.com/api/v2
plugin:tickticksync:22748 There are:  38  tasks in Cache.
plugin:tickticksync:22828 No synchronization changes.
plugin:tickticksync:23463 An error occurred: Error: EISDIR: illegal operation on a directory, read
scheduledSynchronization @ plugin:tickticksync:23463
await in scheduledSynchronization (async)
eval @ plugin:tickticksync:23134
plugin:tickticksync:23467 TickTick scheduled synchronization task completed at 3/21/2024, 11:43:25 AM
plugin:tickticksync:23358 TickTick scheduled synchronization task started at 3/21/2024, 11:46:22 AM
plugin:tickticksync:22747 We have:  38  tasks on https://api.ticktick.com/api/v2
plugin:tickticksync:22748 There are:  38  tasks in Cache.
plugin:tickticksync:22828 No synchronization changes.
plugin:tickticksync:23463 An error occurred: Error: EISDIR: illegal operation on a directory, read
scheduledSynchronization @ plugin:tickticksync:23463
await in scheduledSynchronization (async)
eval @ plugin:tickticksync:22987
plugin:tickticksync:23467 TickTick scheduled synchronization task completed at 3/21/2024, 11:46:24 AM
thesamim commented 3 months ago

Long story short: The "Already Exists" errors should only be seen on first sync. They are not a concern, as the next step is to try to access the folder (or file). If there's truly an issue, the process will stop and notify the users. (The errors are still shown because they help me understand the flow ...)

BUT: the "EISDIR illegal operation..." is a concern. I will be working on that.

Q: Are you using something like SyncThing or Obsidian Sync to share your vaults across machines?

IMXeno123 commented 3 months ago

After many tests and I found that synchronization doesn't work. Tasks can't be updated from TickTick to Obsidian.


Log

plugin:tickticksync:23358 TickTick scheduled synchronization task started at 3/21/2024, 12:03:11 PM
plugin:tickticksync:22747 We have:  39  tasks on https://api.ticktick.com/api/v2
plugin:tickticksync:22748 There are:  39  tasks in Cache.
plugin:tickticksync:22832 An error occurred while synchronizing: TypeError: Cannot read properties of null (reading 'path')
    at t.<anonymous> (app.js:1:737480)
    at app.js:1:237056
    at Object.next (app.js:1:237161)
    at app.js:1:236077
    at new Promise (<anonymous>)
    at v (app.js:1:235822)
    at t.read (app.js:1:737361)
    at FileOperation.updateTaskInFile (plugin:tickticksync:21759:42)
    at async SyncMan.syncTickTickToObsidian (plugin:tickticksync:22819:9)
    at async TickTickSync.scheduledSynchronization (plugin:tickticksync:23365:24)
    at async HTMLDivElement.eval (plugin:tickticksync:22987:9)
syncTickTickToObsidian @ plugin:tickticksync:22832
await in syncTickTickToObsidian (async)
scheduledSynchronization @ plugin:tickticksync:23365
await in scheduledSynchronization (async)
eval @ plugin:tickticksync:22987
plugin:tickticksync:23463 An error occurred: Error: EISDIR: illegal operation on a directory, read
scheduledSynchronization @ plugin:tickticksync:23463
await in scheduledSynchronization (async)
eval @ plugin:tickticksync:22987
plugin:tickticksync:23467 TickTick scheduled synchronization task completed at 3/21/2024, 12:03:11 PM
plugin:tickticksync:23358 TickTick scheduled synchronization task started at 3/21/2024, 12:05:42 PM
plugin:tickticksync:22747 We have:  39  tasks on https://api.ticktick.com/api/v2
plugin:tickticksync:22748 There are:  39  tasks in Cache.
plugin:tickticksync:22832 An error occurred while synchronizing: TypeError: Cannot read properties of null (reading 'path')
    at t.<anonymous> (app.js:1:737480)
    at app.js:1:237056
    at Object.next (app.js:1:237161)
    at app.js:1:236077
    at new Promise (<anonymous>)
    at v (app.js:1:235822)
    at t.read (app.js:1:737361)
    at FileOperation.updateTaskInFile (plugin:tickticksync:21759:42)
    at async SyncMan.syncTickTickToObsidian (plugin:tickticksync:22819:9)
    at async TickTickSync.scheduledSynchronization (plugin:tickticksync:23365:24)
    at async eval (plugin:tickticksync:23134:58)
syncTickTickToObsidian @ plugin:tickticksync:22832
await in syncTickTickToObsidian (async)
scheduledSynchronization @ plugin:tickticksync:23365
await in scheduledSynchronization (async)
eval @ plugin:tickticksync:23134
plugin:tickticksync:23463 An error occurred: Error: EISDIR: illegal operation on a directory, read
scheduledSynchronization @ plugin:tickticksync:23463
await in scheduledSynchronization (async)
eval @ plugin:tickticksync:23134
plugin:tickticksync:23467 TickTick scheduled synchronization task completed at 3/21/2024, 12:05:44 PM
IMXeno123 commented 3 months ago

Long story short: The "Already Exists" errors should only be seen on first sync. They are not a concern, as the next step is to try to access the folder (or file). If there's truly an issue, the process will stop and notify the users. (The errors are still shown because they help me understand the flow ...)

BUT: the "EISDIR illegal operation..." is a concern. I will be working on that.

Q: Are you using something like SyncThing or Obsidian Sync to share your vaults across machines?

Thanks for the work, this is a great tool! I'm not using SyncThing or Obsidian Sync, but I'm using onedrive

thesamim commented 3 months ago

Thanks for the work, this is a great tool! I'm not using SyncThing or Obsidian Sync, but I'm using onedrive

Thanks!

Thanks for the update. Will keep you posted.

thesamim commented 3 months ago

@IMXeno123 : I'm not able to reproduce the "EISDIR illegal operation..." condition. (Even though I too have vaults on OneDrive and am synchronizing with SyncThing to Android.)

But I added some protective code around the file handling. If the error occurs again, it should at least be handled gracefully.

Please update to 1.0.22 and let me know what you see.

If the error does happen again, it would be useful for me to understand HOW it's happening. As in: is the issue that OneDrive is in mid-synchronization while TickTickSync is also synchronizing?

Some useful data points would be:

  1. How many files do you have in your vault?
  2. How many tasks do you have in Ticktick?
  3. How much memory do you have on your machine?
  4. What network speeds are you able to get?

Thanks for your patience, please keep me updated.

LemurTech commented 3 months ago

I have something to add here, hopefully relevant to the current issue.

I have a folder in my vault root, called 'Shared'. This is actually a symbolic link to a folder that exists alongside my PC-filesystem vault folder. I sym-link this folder into two different vaults, so that I can share templates between them. I don't know if this is relevant, but there it is.

Today on v 1.0.22 I created a new folder 'Personal' in 'Shared' and immediately received a popup and an 'EISDIR' error:

image

image

Removing the 'Personal' folder does not remove the error. Adding a file into the 'Personal' folder also does not remove the error. I performed a TickTickSync database check. This also did not result the error.

I wonder if we need to have a way to exclude folders from analysis by TickTickSync.

UPDATE: I removed the entry from data.json. I can see that the other entries have the .md extension, but this one did not. Therein lies the issue, TickTickSync is cataloging a directory instead of a file. I just repeated the experiment with a different, newly-created folder. Same result!

thesamim commented 3 months ago

I have a folder in my vault root, called 'Shared'. This is actually a symbolic link to a folder that exists alongside my PC-filesystem vault folder.

Could you please share the exact command you used to create the Symlink?

LemurTech commented 3 months ago

PowerShell: This will create the junction for 'Shared' in the 'Personal' vault

New-Item -Path "D:\Obsidian\Personal\Shared" -ItemType Junction -Value "D:\Obsidian\Shared"

Issue is happening with folders created anywhere, though. I just tested. For example, this 'Test' folder:

    "Repos/PowerShell/Test": {
      "TickTickTasks": [],
      "TickTickCount": 0
    }
thesamim commented 3 months ago

I tried having a junction in the vault folder, and a junction TO the vault folder

Directory of E:\temp
[...]
03/22/2024  06:08 PM    <JUNCTION>     wtf [\??\C:\Users\Sami Mikhail\OneDrive\Documents\OKB\Testing\otherbar]
Directory of C:\Users\Sami Mikhail\OneDrive\Documents\OKB\Testing
[...]
03/22/2024  05:50 PM    <JUNCTION>     bar [\??\E:\temp\foo]
03/22/2024  02:42 PM    <SYMLINKD>     someDir [E:\dev\testVault\someNewFolder\]
03/22/2024  02:42 PM    <JUNCTION>     someOtherDir [E:\dev\testVault\fackle]
03/22/2024  02:56 PM    <DIR>          Tasks Sync

And not seeing any issues.

Next question: Are any of those directories UNC mapped directories? (as in \\server-name\shared-resource-pathname )

I'm now wondering if network permissions are getting in the way....

LemurTech commented 3 months ago

No, not UNC, just regular old NTFS folders on a non-domain-joined home PC. FWIW, I'm a Windows sysadmin myself, and I'm not seeing anything unusual in my setup (aside from the use of the junction to share my templates/includes/javascript files).

I'm creating a folder just the normal way, by right-clicking at a location in the file explorer tree. It's immediately interpreted by TickTickSync as a file. Recall this was not happening in any previous version, in my experience. I've been creating new folders and files with no complaints from TickTickSync.

thesamim commented 3 months ago

WEIRD!

Any clues in the log?

IMXeno123 commented 3 months ago

@thesamim: I updated to the latest version 1.0.22, and created a blank vault, and everything worked well. I suspect that the file in my vault caused the mistake, and I'm still looking for useful clues. :(

LemurTech commented 3 months ago

This is from my Android. In this case, I believe the file does not exist because I'm not syncing this file type from my PC. But TickTickSync wants to catalog it somehow, and it just gets stuck here.

SmartSelect_20240322_222706_Obsidian

thesamim commented 3 months ago

@LemurTech : That's a use case I had not considered: Files that are not synced... I will have to think through how to get around that. See later...

Regarding folders that show up as files: I've be wracking my brain all night and cannot think of a way this is happening. I believe the only difference between your set up and mine is that you have some folders shared between two machines. If I'm Assuming that you have a mapped drive from one machine to the other with the shared folders. I'm further assuming that you have checked network permissions on both machines. I can't think of anything else that would be getting in the way.

I'm also Assuming that no other plugin, or Obsidian itself, are having any problems with the shared folders. As in: you are able to add notes from both machines to the shared folder. Any other plugin that interacts with those files in those folders is also working fine. If that is the case: Could you please let me know what plugins you're using on those folders? I'd like to see if they are handling file access differently than I am. (I'm only using Obsidian Vault functions.... wondering if they are doing something different....)

@LemurTech, @IMXeno123: The attached file contains a number of band-aid fixes. Let me stress this: they are band-aid fixes to help me understand what's going on. I would not trust this with a real set up at all!

Changes I have made here:

  1. Double check that any file accessed is actually a file, not a folder
  2. IF there's an attempt to add a folder to the fileMetaData, it will prevent the addition and it will throw an error to give me a trace to see where that's happening from
  3. If a file or folder is not found just report the issue in console and attempt to continue processing.

Again: this is not the solution per se. This is an attempt to figure out what's going on because I'm not able to reproduce the errors.

If you are able to test with this, I would appreciate any feedback.

To use, please back up your TickTickSync plugin folder in your vault(s) and extract the following there. TickTickSyn-TEST-1.0.23.zip

Thanks in advance.

LemurTech commented 3 months ago

Files that are not synced - This was interesting. The file in question was a PowerShell .ps1 file, which was an attachment to a regular .md file. This attachment was being synced among my PCs, but not to my Android, which was my intention. I guess this was the only ps1 I had as an attachment. I do have others in my vault, but these are not attachments; they are read by the Code Files plugin, which allows me to edit them via the Monaco code editor. Why would this one show up as an issue?

On one of my PCs, I removed that .ps1 as an attachment and deleted the file from my vault. My Android synced these changes and stopped complaining about the file.

If I were to guess, I would say that Obsidian knows (because of the Code Files plugin) to enumerate these files as it would .md files, in order to process them as text. Your plugin calls on Obsidian to enumerate files as part of its duplicate check (or somesuch). And something is going wrong there. I think you need to ensure that your plugin is only parsing .md files and no other text files.

The folders being treated as files is peculiar. I am certain this has nothing to do with my use of the junction to share a folder between vaults, because I have reproduced this issue on a separate PC where no such linking is happening. To explain: the junction allows me to share a folder that exists outside of the vault structure with two separate vaults on the same PC. The shared folder exists within the SAME FOLDER that houses the two vaults, and it partakes of the same NTFS permissions. But when these vaults are synced to another PC, the junction no longer applies, and the (originally shared) folder gets synced as a regular NTFS folder.

There is the possibility that some other plugin is causing issues. I have a lot of plugins. But thinking of the ones that interpret folders.... I'd consider "Folder Notes" and "Metadata Menu" as top contenders. That said, I disabled them, restarted Obsidian, and was still able to reproduce the issue.

I'll try your 'test' files and see what I can report.

LemurTech commented 3 months ago

Installed 'test' plugin. Still had "Test" folder from before. Saw:

Duplicate check Skipping KB/Test because it's a folder.

Deleted folder in question, saw:

Duplicate check Skipping KB/Test because it's not found.

Created "New Test" folder, synced, saw:

Duplicate check Skipping KB/New Test because it's a folder.

thesamim commented 3 months ago

Do you see an error that looks like "Not adding ", filepath, " to Metadata because it's a folder." in the log?

LemurTech commented 3 months ago

Do you see an error that looks like "Not adding ", filepath, " to Metadata because it's a folder." in the log?

I've seen no sign of that one.

LeslieP-TX commented 3 months ago

Good evening. New user, have been moving tasks around in both TickTick and Obsidian, so I'm sure this is an artifact of a task that started on one page and is now on another, but I'm also getting the duplicate check failed: file not found or locked. Same message, just this one location. Happens at every sync. There file not found is actually a subdirectory, there was never a 2022.md file. Is there a way to just sort of "start over" with the sync process so the plugin can look at ticktick and look at obsidian "fresh" and figure things out from there?

image

thesamim commented 3 months ago

@LeslieP-TX

Is there a way to just sort of "start over" with the sync process so the plugin can look at ticktick and look at obsidian "fresh" and figure things out from there?

Please check out: https://github.com/thesamim/TickTickSync/wiki/Reset-to-TickTick

Please note the large caution at the top of the page. :)

LeslieP-TX commented 3 months ago

Reset worked perfectly, errors seem to be gone. Many thanks!

thesamim commented 3 months ago

Glad that helped.

thesamim commented 2 months ago

@LeslieP-TX , @LemurTech , @IMXeno123 : I believe I've taken care of all the issues. If you find anything, please open a new issue so we cant track that way.

Thanks.