jkent / frogfs

Fast Read-Only General-purpose File System (ESP-IDF and ESP8266_RTOS_SDK compatible)
https://frogfs.readthedocs.io
Mozilla Public License 2.0
25 stars 32 forks source link

mkfrogfs.py fails if root dir has subdirectories starting with dot (next branch) #49

Closed valkuc closed 12 months ago

valkuc commented 12 months ago

Hello. The directory structure is like this: /.test_dot_dir/.test.html

Result:
       - Stage 1
         - test_dot_dir/.test.html
Traceback (most recent call last):
  File "E:\Espressif\workspace\test_proj\managed_components\frogfs\tools\mkfrogfs.py", line 511, in <module>
    dirty |= run_preprocessors(entries)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\Espressif\workspace\test_proj\managed_components\frogfs\tools\mkfrogfs.py", line 324, in run_preprocessors
    preprocess(entry)
  File "E:\Espressif\workspace\test_proj\managed_components\frogfs\tools\mkfrogfs.py", line 261, in preprocess
    with open(os.path.join(g_root_dir, path), 'rb') as f:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '\\test_dot_dir/.test.html'

It looks like the dot is removed from directory name in mkfrogfs.py

jkent commented 12 months ago

Hmm, looks like changing .lstrip('.').lstrip('/') to .lstrip('./') on lines 112 and 136, that should solve that problem. Could you try this and report back?

valkuc commented 12 months ago

Looks like did not help. Nothing changed, same error. Actually, I'm thinking that it's a good idea to skip files (and directories) with name starting from "." and do not include them in FrogFs image. What do you think?

valkuc commented 12 months ago

Btw, I tried to implement such exclusion by adding

    if reldir.startswith('.'):
            continue

at lines 113 and 139, but this not helped and I'm stuck. My Python knowledge is below zero :)

jkent commented 12 months ago

fixed in 1a3d571bbe23db53e586a6211a9917324a5a3917

Thanks!

valkuc commented 12 months ago

Thanks, now there is no errors and the directory with file is added to FrogFs image. Could you please tell me, is it possible to exclude any or specific directory from image?

jkent commented 12 months ago

You can do the following, which glob matches any files and folders with that name:

filters:
  'path/to/.folder_name*':
    - discard

I'll create a bug, because you should be able to just do the following:

filters:
  'path/to/.folder_name':
    - discard

But that is currently broken.

valkuc commented 12 months ago

Looks like this doesn't work either. In the log:

       - Stage 1
         - .test-data/state.json
           - compress deflate... skipped

but actually the file is included as I see it in binary.

jkent commented 12 months ago

I'll look into this. In the meantime, can you open a new issue with a snippet of your yaml?

valkuc commented 12 months ago

Yep,will do