mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-15 10:13:15 -05:00
ignore macOS specific files
This commit is contained in:
parent
4a52d346f9
commit
f8afbae2cd
@ -36,8 +36,19 @@ def _tags_from_path(filepath):
|
|||||||
return tag_ids
|
return tag_ids
|
||||||
|
|
||||||
|
|
||||||
|
def _is_ignored(filepath):
|
||||||
|
# https://github.com/jonaswinkler/paperless-ng/discussions/1037
|
||||||
|
basename = os.path.basename(filepath)
|
||||||
|
if basename == ".DS_STORE":
|
||||||
|
return True
|
||||||
|
if basename.startswith("._"):
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def _consume(filepath):
|
def _consume(filepath):
|
||||||
if os.path.isdir(filepath):
|
if os.path.isdir(filepath) or _is_ignored(filepath):
|
||||||
return
|
return
|
||||||
|
|
||||||
if not os.path.isfile(filepath):
|
if not os.path.isfile(filepath):
|
||||||
@ -71,6 +82,9 @@ def _consume(filepath):
|
|||||||
|
|
||||||
|
|
||||||
def _consume_wait_unmodified(file):
|
def _consume_wait_unmodified(file):
|
||||||
|
if _is_ignored(file):
|
||||||
|
return
|
||||||
|
|
||||||
logger.debug(f"Waiting for file {file} to remain unmodified")
|
logger.debug(f"Waiting for file {file} to remain unmodified")
|
||||||
mtime = -1
|
mtime = -1
|
||||||
current_try = 0
|
current_try = 0
|
||||||
|
@ -60,10 +60,10 @@ class ConsumerMixin:
|
|||||||
|
|
||||||
super(ConsumerMixin, self).tearDown()
|
super(ConsumerMixin, self).tearDown()
|
||||||
|
|
||||||
def wait_for_task_mock_call(self):
|
def wait_for_task_mock_call(self, excpeted_call_count=1):
|
||||||
n = 0
|
n = 0
|
||||||
while n < 100:
|
while n < 100:
|
||||||
if self.task_mock.call_count > 0:
|
if self.task_mock.call_count >= excpeted_call_count:
|
||||||
# give task_mock some time to finish and raise errors
|
# give task_mock some time to finish and raise errors
|
||||||
sleep(1)
|
sleep(1)
|
||||||
return
|
return
|
||||||
@ -202,6 +202,26 @@ class TestConsumer(DirectoriesMixin, ConsumerMixin, TransactionTestCase):
|
|||||||
|
|
||||||
self.assertRaises(CommandError, call_command, 'document_consumer', '--oneshot')
|
self.assertRaises(CommandError, call_command, 'document_consumer', '--oneshot')
|
||||||
|
|
||||||
|
def test_mac_write(self):
|
||||||
|
self.task_mock.side_effect = self.bogus_task
|
||||||
|
|
||||||
|
self.t_start()
|
||||||
|
|
||||||
|
shutil.copy(self.sample_file, os.path.join(self.dirs.consumption_dir, ".DS_STORE"))
|
||||||
|
shutil.copy(self.sample_file, os.path.join(self.dirs.consumption_dir, "my_file.pdf"))
|
||||||
|
shutil.copy(self.sample_file, os.path.join(self.dirs.consumption_dir, "._my_file.pdf"))
|
||||||
|
shutil.copy(self.sample_file, os.path.join(self.dirs.consumption_dir, "my_second_file.pdf"))
|
||||||
|
shutil.copy(self.sample_file, os.path.join(self.dirs.consumption_dir, "._my_second_file.pdf"))
|
||||||
|
|
||||||
|
sleep(5)
|
||||||
|
|
||||||
|
self.wait_for_task_mock_call(excpeted_call_count=2)
|
||||||
|
|
||||||
|
self.assertEqual(2, self.task_mock.call_count)
|
||||||
|
|
||||||
|
fnames = [os.path.basename(args[1]) for args, _ in self.task_mock.call_args_list]
|
||||||
|
self.assertCountEqual(fnames, ["my_file.pdf", "my_second_file.pdf"])
|
||||||
|
|
||||||
|
|
||||||
@override_settings(CONSUMER_POLLING=1, CONSUMER_POLLING_DELAY=1, CONSUMER_POLLING_RETRY_COUNT=20)
|
@override_settings(CONSUMER_POLLING=1, CONSUMER_POLLING_DELAY=1, CONSUMER_POLLING_RETRY_COUNT=20)
|
||||||
class TestConsumerPolling(TestConsumer):
|
class TestConsumerPolling(TestConsumer):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user