CaptainDario / DaKanji

You are learning Japanese? Then you need to give DaKanji a try!
https://dakanji.app
Other
66 stars 4 forks source link

Modify Dakanji's cache folder location #85

Closed BeyondMagic closed 2 months ago

BeyondMagic commented 2 months ago

Please, let us set the cache/configuration folder for Dakanji outside the user's home.

image

It looks out of place and there are better places for it to be, like or ~/.config/dakanji, or~/.local/share/.

CaptainDario commented 2 months ago

Where is this exactly located? DaKanji should place the data inside the user's documents folder not the home.

Currently, DaKanji uses xdg to get a path to the documents folder.

BeyondMagic commented 2 months ago

Currently it is located at ~/Dakanji: image

By documents folder you mean XDG_DATA_HOME? If so, it's not following that. Could you specify which one of the specification, please?

CaptainDario commented 2 months ago

Currently, DaKanji uses the path_provider plugin which in turn uses the xdg_directories plugin. The line being called is this one.

return Future<String?>.value(xdg.getUserDirectory('DOCUMENTS')?.path);

I would assume that this is the documents folder inside the user's home directory. I may switch to the application's support directory, but I am not sure to what this will resolve on linux.

 @override
  Future<String?> getApplicationSupportPath() async {
    final Directory directory =
        Directory(path.join(xdg.dataHome.path, await _getId()));
    if (directory.existsSync()) {
      return directory.path;
    }

Which should resolve to this

dataDirs - The list of preference-ordered base directories relative to which data files should be searched. (Corresponds to $XDG_DATA_DIRS).

Currently, I do not have a Linux machine available to test this. If you have time to test a build using this path I can make one and if everything is going well switch to that. I think a setting for this will be a bit problamatic.

BeyondMagic commented 2 months ago

I will try and build it, thank you.

CaptainDario commented 2 months ago

No, worries I can build it in GitHub actions I just cannot run it. I am going to ping you here once it is done.

BeyondMagic commented 2 months ago
return Future<String?>.value(xdg.getUserDirectory('DOCUMENTS')?.path);

This is a very unfortunate line that does not follow XDG specification at all. The coder(s) seemed to want to make its own standard with it.

I believe it'd be better and easier to use:

dataHome - The single base directory relative to which user-specific data files should be written. (Corresponds to $XDG_DATA_HOME).

from the xdg_directories plugin you mentioned. But it is your call, I thank you nonetheless for building it and I'll test it when it is done.

CaptainDario commented 2 months ago

To be honest, I am very inexperienced in developing specifically for Linux so I cannot say if this is a bad line. However, it's from the Flutter team so at least it's a credible team.

If I understand it correctly this will result in a path that is not usually accessed by the user ie.: not his/her home directory. I changed the according code and will create a beta release today. If you have some time I would also appreciate if you could test out the new features on Linux because as I mentioned before, I do not have a Linux setup currently.

BeyondMagic commented 2 months ago

No problems, I will test it, thank you.

CaptainDario commented 2 months ago

Here you go. Let me know if this is the behavior you expect. The path where the files are stored should be printed when you run DaKanji from the command line. As this is a beta version of the upcoming 3.4 release, I would highly appreciate it if you could also test the new features.

BeyondMagic commented 2 months ago

Hey, just tested out the issue. It is resolved, thank you. I am going to try out the features, but I'm still figuring the application out -- although it's quite amazing what you've made, and for being full open source you get a special virtual hug :)

I'll close the issue when I test it all.

CaptainDario commented 2 months ago

Thank you for the nice words and also thank you for using and testing DaKanji!

CaptainDario commented 2 months ago

Are you using the portable, snap or flatpak? Where are those files located now?

BeyondMagic commented 2 months ago

I am using the portable version, the files are located at $XDG_DATA_HOME/com.DaAppLab.DaKanji:

 com.DaAppLab.DaKanji § ls **/*                                                                                                                                                       
+----+------------------------------------------+------+-----------+--------------+
|  # |                   name                   | type |   size    |   modified   |
+----+------------------------------------------+------+-----------+--------------+
|  0 | DaKanji                                  | dir  |   4.0 KiB | 3 hours ago  |
+----+------------------------------------------+------+-----------+--------------+
|  1 | DaKanji/assets                           | dir  |   4.0 KiB | a day ago    |
+----+------------------------------------------+------+-----------+--------------+
|  2 | DaKanji/assets/__MACOSX                  | dir  |   4.0 KiB | a day ago    |
+----+------------------------------------------+------+-----------+--------------+
|  3 | DaKanji/assets/__MACOSX/ipadic           | dir  |   4.0 KiB | a day ago    |
+----+------------------------------------------+------+-----------+--------------+
|  4 | DaKanji/assets/dict                      | dir  |   4.0 KiB | a day ago    |
+----+------------------------------------------+------+-----------+--------------+
|  5 | DaKanji/assets/dict/dictionary.isar      | file | 340.0 MiB | 18 hours ago |
+----+------------------------------------------+------+-----------+--------------+
|  6 | DaKanji/assets/dict/dictionary.isar.lock | file |   4.0 KiB | 3 hours ago  |
+----+------------------------------------------+------+-----------+--------------+
|  7 | DaKanji/assets/dict/examples.isar        | file | 308.3 MiB | 18 hours ago |
+----+------------------------------------------+------+-----------+--------------+
|  8 | DaKanji/assets/dict/examples.isar.lock   | file |   4.0 KiB | 3 hours ago  |
+----+------------------------------------------+------+-----------+--------------+
|  9 | DaKanji/assets/dict/krad.isar            | file |   3.9 MiB | 18 hours ago |
+----+------------------------------------------+------+-----------+--------------+
| 10 | DaKanji/assets/dict/krad.isar.lock       | file |   4.0 KiB | 3 hours ago  |
+----+------------------------------------------+------+-----------+--------------+
| 11 | DaKanji/assets/dict/radk.isar            | file |   2.6 MiB | 18 hours ago |
+----+------------------------------------------+------+-----------+--------------+
| 12 | DaKanji/assets/dict/radk.isar.lock       | file |   4.0 KiB | 3 hours ago  |
+----+------------------------------------------+------+-----------+--------------+
| 13 | DaKanji/assets/ipadic                    | dir  |   4.0 KiB | a day ago    |
+----+------------------------------------------+------+-----------+--------------+
| 14 | DaKanji/assets/ipadic/char.bin           | file | 256.3 KiB | a day ago    |
+----+------------------------------------------+------+-----------+--------------+
| 15 | DaKanji/assets/ipadic/dicrc              | file |     693 B | a day ago    |
+----+------------------------------------------+------+-----------+--------------+
| 16 | DaKanji/assets/ipadic/left-id.def        | file |  54.6 KiB | a day ago    |
+----+------------------------------------------+------+-----------+--------------+
| 17 | DaKanji/assets/ipadic/matrix.bin         | file |   3.3 MiB | a day ago    |
+----+------------------------------------------+------+-----------+--------------+
| 18 | DaKanji/assets/ipadic/mecabrc            | file |       0 B | a day ago    |
+----+------------------------------------------+------+-----------+--------------+
| 19 | DaKanji/assets/ipadic/pos-id.def         | file |   1.4 KiB | a day ago    |
+----+------------------------------------------+------+-----------+--------------+
| 20 | DaKanji/assets/ipadic/rewrite.def        | file |   6.1 KiB | a day ago    |
+----+------------------------------------------+------+-----------+--------------+
| 21 | DaKanji/assets/ipadic/right-id.def       | file |  54.6 KiB | a day ago    |
+----+------------------------------------------+------+-----------+--------------+
| 22 | DaKanji/assets/ipadic/sys.dic            | file |  46.9 MiB | a day ago    |
+----+------------------------------------------+------+-----------+--------------+
| 23 | DaKanji/assets/ipadic/unk.dic            | file |   5.6 KiB | a day ago    |
+----+------------------------------------------+------+-----------+--------------+
| 24 | DaKanji/searchhistory.sqlite             | file |  12.0 KiB | 3 hours ago  |
+----+------------------------------------------+------+-----------+--------------+
| 25 | DaKanji/wordlists.sqlite                 | file | 272.0 KiB | a day ago    |
+----+------------------------------------------+------+-----------+--------------+
| 26 | shared_preferences.json                  | file |   2.9 KiB | a minute ago |
+----+------------------------------------------+------+-----------+--------------+
|  # |                   name                   | type |   size    |   modified   |
+----+------------------------------------------+------+-----------+--------------

Sorry for only responding now, 18 hours ago I was studying Japanese for a test :|

I am going to need help though to test a few things, I'll join in Discord to ask a few questions about where these new features are located.

CaptainDario commented 2 months ago

Thank you! This location seems way better than before

BeyondMagic commented 2 months ago

The images do not show up, I tested it out on my phone with the same Kanji to see if it was supposed to, and also looked at the settings to see if there was an option to enable it, but found none (maybe I am blind [maybe].)

image

CaptainDario commented 2 months ago

Thank you so much! You are right, I totally forgot that the image search is only available on mobile (iOS, Android). This is due to a limitation in Flutter #3