obsidian-git: [Bug]: InternalError on iOS when Tasks is installed
Describe the bug
I get this error:
And the backup is not completed. To solve the issue, I have to not install Tasks, and clone again the repository.
Relevant errors (if available)
InternalError: An internal error caused this command to fail. Please file a bug report at
https://github.com/isomorphic-git/isomorphic-git/issues
with this error message: SHA check failed! Expected 27eb43e79ec4b1236d2ba1b27e738f279420bd93,
computed b77dOb17f624d487b84cc67d4510794aeb349819
Steps to reproduce
The steps I am doing:
- Created a new vault.
- Clone a repository from Github.
- The repository has
.obsidian
. - Set depth to
1
.
No issues so far. Then…
- Edit a note.
- Run
Obsidian Git: Create backup
- Backup is complete
No issues so far. Then…
- Install the Tasks plugin (https://publish.obsidian.md/tasks/)
- Run
Obsidian Git: Create backup
- I get the mentioned error
- Backup is not done
Expected Behavior
No response
Addition context
Obsidian: 1.4.4 (98) << From TestFligth Also tested with the stable release from the AppStore.
iPhone 12 iOS: 16.4.1 Calendar: 1.5.10 Dataview: 0.5.55 Obsidian Git: 2.19.1
No other plugin installed on my phone.
Operating system
iOS
Installation Method
Other
Plugin version
2.19.1
About this issue
- Original URL
- State: open
- Created a year ago
- Comments: 42 (1 by maintainers)
The error message
is a cryptic way to say that the
.git/index
file is broken. The file consists of 3 parts:The error message says that the hash over the first two parts is not correct.
Isomorphic-git has the class GitIndexManager.js which maintances the
.git/index
file. The class ensures that the file has a proper format, the hash is always computed when the list in 2. changed and has a lock to ensure that concurrent writes that could corrupt the file can never occur. In isomorphic-git the.git/index
is never directy accessed, only through the GitIndexManager class.In the obsidian-git repository there is a file:
myAdapter.ts
which contains the following code that overwrites the.git/index
:Why do you do this?
The issue in isomorohic-git: https://github.com/isomorphic-git/isomorphic-git/issues/1760
I’m also having this issue and I’ve tried with a clean new vault, with only two plugins (Excalidraw and Obsidian-Git).
Obsidian-Git version: 2.20.5 iPad iOS version: 16.5.1
Im not sure how to resolve this issue and I’m hoping there will be a solution soon, because this plugin is awesome 😃
At least make your vault sync properly again, people, you don’t have to stuck here. Good luck! (me 2 months ago)
@Vinzent03 As I said in the note above, the
GitIndexManager.js
has a lock, that ensures that concurrent writing to the index results in a valid index file. You delegate the writing to thesaveAndClear
function, which pushes the write outside the lock context and with this concurrent writes are possible. As far as I understand the implementation you pull before you commit. Both can update the index. If you look at the first image in this thread you seewhich has the wrong order. I think this is a race problem, but I have no evidence jet.
With your implementation you only save the reading of the index file, but the file has to be parsed each time. A better way to improve performance is to use the isomorphic git cache:
https://isomorphic-git.org/docs/en/cache
Create a global cache object, pass this to the function calls and flush the cache from time to time. You get better performance because you cache pared objects and you relay on the official api.