feat: add memosignore

This commit is contained in:
arkohut 2024-09-14 18:12:21 +08:00
parent 9d64dbc69b
commit a4a3387bdc
2 changed files with 13 additions and 2 deletions

View File

@ -17,6 +17,7 @@ from magika import Magika
from .config import settings
from .models import init_database
from .initialize_typesense import init_typesense
import pathspec
IS_THUMBNAIL = "is_thumbnail"
@ -141,6 +142,13 @@ def show(library_id: int):
async def loop_files(library_id, folder, folder_path, force, plugins):
# Read .memosignore file
ignore_spec = None
memosignore_path = Path(folder_path) / '.memosignore'
if memosignore_path.exists():
with open(memosignore_path, 'r') as ignore_file:
ignore_spec = pathspec.PathSpec.from_lines('gitwildmatch', ignore_file)
updated_file_count = 0
added_file_count = 0
scanned_files = set()
@ -155,7 +163,9 @@ async def loop_files(library_id, folder, folder_path, force, plugins):
for file in files:
file_path = Path(root) / file
absolute_file_path = file_path.resolve() # Get absolute path
if file in ignore_files:
relative_path = absolute_file_path.relative_to(folder_path)
if file in ignore_files or (ignore_spec and ignore_spec.match_file(str(relative_path))):
continue
scanned_files.add(str(absolute_file_path))

View File

@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "memos"
version = "0.6.11"
version = "0.6.12"
description = "A package for memos"
readme = "README.md"
authors = [{ name = "arkohut" }]
@ -43,6 +43,7 @@ dependencies = [
"einops",
"modelscope",
"mss",
"pathspec",
]
[project.urls]