sync cleanup
This commit is contained in:
1 parent
263f18a1df
commit
de20ed726f
4 files changed
+2
-43
No files matched your search
@@ -91,7 +91,6 @@ provider_root = value('provider')['root'] # env('SYNC_PROVIDER', 'fs')
|
|||||||
|
|
||||||
f = abs_fn(provider_root)
|
f = abs_fn(provider_root)
|
||||||
|
|
||||||
dir_documents = './Documents'
|
|
||||||
dir_articles = './Articles'
|
dir_articles = './Articles'
|
||||||
dir_pages = './Pages'
|
dir_pages = './Pages'
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ from tempfile import mkstemp
|
|||||||
|
|
||||||
import settings
|
import settings
|
||||||
from db import collection
|
from db import collection
|
||||||
from sync.data import scan_subdirs, request
|
from sync.data import request
|
||||||
from sync.models import Model
|
from sync.models import Model
|
||||||
from sync.models.DocumentPreviewImage import DocumentPreviewImage
|
from sync.models.DocumentPreviewImage import DocumentPreviewImage
|
||||||
from utils.hash import hash_str, md5
|
from utils.hash import hash_str, md5
|
||||||
@@ -25,12 +25,6 @@ class Document(Model):
|
|||||||
async def delete(query):
|
async def delete(query):
|
||||||
return store.find_one_and_delete(query)
|
return store.find_one_and_delete(query)
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
async def scan(provider):
|
|
||||||
scan_dir = settings.dir_documents
|
|
||||||
paths = scan_subdirs(provider, '.pdf', scan_dir)
|
|
||||||
return [Document.read_path(provider, path) for path in paths]
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def read_path(provider, path):
|
def read_path(provider, path):
|
||||||
name = os.path.basename(path)
|
name = os.path.basename(path)
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ from typing import Optional, List
|
|||||||
|
|
||||||
import settings
|
import settings
|
||||||
from db import collection
|
from db import collection
|
||||||
from sync.data import request, list_images
|
from sync.data import request
|
||||||
from sync.models import Model
|
from sync.models import Model
|
||||||
from utils.hash import md5, hash_str
|
from utils.hash import md5, hash_str
|
||||||
from utils.image import image_magick_resize
|
from utils.image import image_magick_resize
|
||||||
@@ -54,13 +54,6 @@ class Image(Model):
|
|||||||
|
|
||||||
return img
|
return img
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
async def scan(provider):
|
|
||||||
scan_path = settings.dir_images
|
|
||||||
documents = list_images(provider, scan_path)
|
|
||||||
|
|
||||||
return [Image.read_path(provider, i) for i in documents]
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def read_path(provider, path):
|
def read_path(provider, path):
|
||||||
return Image(
|
return Image(
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
import unittest
|
|
||||||
|
|
||||||
import settings
|
|
||||||
from sync.data import scan_subdirs
|
|
||||||
from sync.data.fs import FSProvider
|
|
||||||
|
|
||||||
|
|
||||||
class MyTestCase(unittest.TestCase):
|
|
||||||
def test_document(self):
|
|
||||||
p = FSProvider(settings.dir_documents)
|
|
||||||
|
|
||||||
documents = scan_subdirs(p, '.pdf')
|
|
||||||
# documents = lmap(
|
|
||||||
# lambda document: create_document(p, document),
|
|
||||||
# documents
|
|
||||||
# )
|
|
||||||
|
|
||||||
self.assertEqual(True, True)
|
|
||||||
|
|
||||||
def test_scan(self):
|
|
||||||
p = FSProvider(settings.dir_documents)
|
|
||||||
documents = scan_subdirs(p, '.pdf')
|
|
||||||
self.assertIsInstance(documents, list)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
unittest.main()
|
|
||||||
Reference in new issue
Block a user