54 Commits

Author SHA1 Message Date
83d122d06f Note.oid: The oid is now only empty when the file hasn't yet been saved 2022-01-20 17:51:32 +01:00
b38c97454b Compute the file hash on saving a note
It's not ideal as the hash is now calculated twice, but it simplifies
such a large porition of the code as I can put proper asserts to make
sure all Files in the NotesFolderFS always have a valid GitHash.
2022-01-20 15:43:22 +01:00
7bdf52165c Ensure the Note's file is reloaded on reloading the Note
Also add more asserts.
2022-01-20 14:34:48 +01:00
802b177d3e Remove invalid assert
This will happen when a note is modified or a new note is added.
2022-01-20 14:05:47 +01:00
61e5304991 Ensure the File oid is never empty
This shouldn't be happening
2022-01-20 13:39:30 +01:00
812860aa78 FlattenedNotesFolders: Update the note internally when modified
This wasn't needed before as notes were passed by reference. Whereas
they are now immutable.
2022-01-20 12:26:58 +01:00
7fce95c187 Make Note class immutable
This greatly simplifies the entire data flow. Though, it comes at the
risk of introducing bugs, but I think it's worth it.

Plus, it makes everything far far more testable.
2022-01-18 21:42:56 +01:00
a6eb613b5a Fix note renaming 2022-01-14 17:09:41 +01:00
0488714e89 Refactor note file naming logic
I want to make the note class immutable, and the file path naming logic
is the toughest part.
2022-01-14 12:55:27 +01:00
e2b6d94eda analyzer: Fix unnecessry includes 2022-01-13 19:03:16 +01:00
f4e8437c91 FolderTree: Subfolders shouldn't show the full path 2022-01-13 18:27:10 +01:00
0441bc51e2 Enable assert 2022-01-07 16:08:35 +01:00
0997844e4e FlattenedNotesFolder: Optimize
Using a list causes quite a big slowdown when inserting notes as one has
to check if the note has already been inserted.
2022-01-05 15:51:32 +01:00
4d337c3d6f Find index numbers in the FlattenedNotesFolder
I'm an idiot
2022-01-05 15:27:25 +01:00
787fd783b7 Reload the FileStorage cache if it is missing items
I'm not sure if this is a good idea as it results in the same Repo being
rebuilt again and again and again.
2021-12-29 11:20:28 +01:00
fce67766db Fix renaming a new note
Don't propogate the signals as that note isn't attached to a folder so
far. This method of renaming is too hacky.
2021-12-22 21:35:15 +01:00
812a7b5263 FlattenedNotesFolder: Fix note index 2021-12-22 21:30:39 +01:00
8867e13c16 FilteredNotesFolder: Implement it properly
I wasn't taking folders which have finished loading into account.
2021-12-20 15:02:38 +01:00
073de700e5 Avoid double flattening 2021-12-20 09:28:00 +01:00
7830737a17 cleanup 2021-12-20 09:28:00 +01:00
ff1f944761 Extra assert 2021-12-20 09:28:00 +01:00
2fecc1ab1d NotesFolderFS: Do not replace the original folder on load
Otherwise the notifiers are lost.
2021-12-20 09:28:00 +01:00
f4fc349e99 NotesFolderNotifier: More asserts 2021-12-20 09:28:00 +01:00
4c95e739ed Always update the entityMap 2021-12-20 09:28:00 +01:00
391ad685a8 NotesFolderFS: Update the entity map as well
urgh.
2021-12-20 09:28:00 +01:00
60b2922176 NotesFolder: Only notify if modified if really modified
Reloading the note doesn't count as a modification
2021-12-20 09:28:00 +01:00
559b0495d2 Make the sorting stable 2021-12-20 09:28:00 +01:00
a5de1e1435 Minor optimization 2021-12-20 09:28:00 +01:00
1bd735940b FlattenedNotesFolder: Do not allow duplicates
And make everything a bit faster.
2021-12-20 09:28:00 +01:00
98b81a74a8 NotesCache: Load the notes properly
Not sure why I ever added this 'addFile' method.
2021-12-20 09:28:00 +01:00
5f8a4d7de3 Repo: Avoid mutable state
The repoFolder can no longer ever be renamed. If it needs to be, then
the GitJournalRepo object, must be reconstructed. This simplifies the
entire code base enourmously, as I can mark tons of variables as 'final'
and I don't need to remember to reinitialize complex dependencies when
the repoPath changes.
2021-12-10 16:02:36 +01:00
87202dc590 Builders: Output their size
It's just nice to know
2021-12-08 14:45:30 +01:00
81b6ebe2f5 lint: avoid-ignoring-return-values++ 2021-11-17 18:10:59 +01:00
e5eb8c1576 lint: avoid-ignoring-return-values++ 2021-11-17 18:10:59 +01:00
5b71a936d2 Remove late
It's default value matters.
2021-11-15 12:39:12 +01:00
e589d1c1eb Experiment with a CalendarView 2021-11-15 12:39:12 +01:00
015659d58f Allow a note to be renamed to whatever
Earlier one could never change a note type, and therefore its extension.
Now you can rename a note's filename to whatever and accordingly the
editor will change.

A warning message is shown when changing the file type.

Fixes #474
2021-11-15 12:39:12 +01:00
a149371a44 Map EditorTypes with NoteFileFormat
Certain Editors only support certain file formats. We can create an
editor either by -

* Giving it a Note, and letting it choose an editor based on the default
/ note metadata
* New Note with a file type
* New Note with a editor type + possible file type
2021-11-09 15:43:57 +01:00
d786edd920 NotesCache: Move directory creation code to NotesFolderFS 2021-11-07 18:11:04 +01:00
2ca51c70d7 Rename new notes correctly 2021-11-07 16:32:32 +01:00
e1ea7a4953 Fetch the modified + created time from git
Fixes #78

This is probably the largest commit that I have ever made. From now on -
every File always has an mtime and ctime which is fetched from git.
Notes can optionally override that time by providing yaml metadata.

Additionally the 'filePath' and 'folderPath' is now relative to the
repoPath instead of being the full path.

This will slow down GitJournal like crazy as all the mtimes and ctime
still need to be cached. For my test repo it takes about 23 seconds for
GitJournal to become responsive.
2021-10-26 17:49:08 +02:00
e332860ea7 NotesFolderFS: A modified file can not be a Note 2021-10-23 16:47:44 +02:00
fa4ad38f27 SortingFunction: Operate on Files
All of these fields aren't specific to a Note any more.
2021-10-20 16:27:15 +02:00
f4f68da005 IgnoredFile: Include the underlying error 2021-10-20 10:13:20 +02:00
3fc6be2854 IgnoredFile: Add InvalidEncoding as a Reason
It'll be easier for the user to figure out what is wrong without seeing
the actual exception.
2021-10-20 10:08:01 +02:00
7a56d0f423 Remove Note's default constructor
Instead there is a new type called 'UnopenedFile'. This was part of my
effort to not have everything inside the 'Note' class and to make it a
bit more immutable.

But, wow, this took a very long time. The 'Note' class seems to be very
deeply integrated everywhere.
2021-10-18 13:03:22 +02:00
0d9c4d8250 NotesFolderFS: Make sure all the Notes are not reloaded each time 2021-10-17 22:26:30 +02:00
5f07543db2 Remove Note's doc setter
This makes us one step closer to making the Note class immutable which
will help GitJournal's overall architecture a lot. Plus it makes me one
step closer to having proper web support.
2021-10-17 22:22:33 +02:00
5366c77ab3 Fix FilteredFlattenedNotesFolder
I'm not sure how this ever worked. The 'contains' function matches all
parts of the note.
2021-10-16 12:17:45 +02:00
7f9beb0d5c NoteFileTypes: Hook up selector to the settings 2021-10-15 17:33:19 +02:00