fix: scan the current folder when otag scan gets no path

This commit is contained in:
randogoth 2026-10-24 21:26:05 +03:00
parent 042a60713a
commit 53b495249b
2 changed files with 14 additions and 1 deletions

View file

@ -567,7 +567,8 @@ class OrvaniTag:
def scan(self, path: str, recursive: bool=False):
for (root,dirs,files) in os.walk(path, topdown=True):
# os.walk('') yields nothing, so an empty path means the current folder
for (root,dirs,files) in os.walk(path or '.', topdown=True):
# process every file with a reader plugin
if self.ENABLE_PLUGINS:

View file

@ -131,3 +131,15 @@ def test_write_uses_config_of_the_files_folder(cwd):
OrvaniTag().add('sub/doc.pdf', '#lofi')
assert OrvaniTag().write_metadata('sub/doc.pdf', 'pdf') == [6, 'pdf']
def test_cmd_scan_defaults_to_current_folder(cwd, monkeypatch):
(cwd / 'sub').mkdir()
writer = PdfWriter()
writer.add_blank_page(72, 72)
writer.add_metadata({'/Keywords': '#lofi'})
writer.write(cwd / 'sub' / 'doc.pdf')
monkeypatch.setattr(sys, 'argv', ['otag', 's'])
main()
assert (cwd / 'sub' / orvani.CONTEXT_FILE).read_text() == 'doc.pdf --- #lofi\n'