fixed nextcloud import first item
This commit is contained in:
parent
429607e1fe
commit
561c2106ce
@ -9,6 +9,8 @@ from cookbook.models import Recipe, RecipeImport, SyncLog
|
|||||||
from cookbook.provider.provider import Provider
|
from cookbook.provider.provider import Provider
|
||||||
from requests.auth import HTTPBasicAuth
|
from requests.auth import HTTPBasicAuth
|
||||||
|
|
||||||
|
from recipes.settings import DEBUG
|
||||||
|
|
||||||
|
|
||||||
class Nextcloud(Provider):
|
class Nextcloud(Provider):
|
||||||
|
|
||||||
@ -28,15 +30,18 @@ class Nextcloud(Provider):
|
|||||||
def import_all(monitor):
|
def import_all(monitor):
|
||||||
client = Nextcloud.get_client(monitor.storage)
|
client = Nextcloud.get_client(monitor.storage)
|
||||||
|
|
||||||
|
if DEBUG:
|
||||||
|
print(f'TANDOOR_PROVIDER_DEBUG checking path {monitor.path} with client {client}')
|
||||||
|
|
||||||
files = client.list(monitor.path)
|
files = client.list(monitor.path)
|
||||||
|
|
||||||
try:
|
if DEBUG:
|
||||||
files.pop(0) # remove first element because its the folder itself
|
print(f'TANDOOR_PROVIDER_DEBUG file list {files}')
|
||||||
except IndexError:
|
|
||||||
pass # folder is empty, no recipes will be imported
|
|
||||||
|
|
||||||
import_count = 0
|
import_count = 0
|
||||||
for file in files:
|
for file in files:
|
||||||
|
if DEBUG:
|
||||||
|
print(f'TANDOOR_PROVIDER_DEBUG importing file {file}')
|
||||||
path = monitor.path + '/' + file
|
path = monitor.path + '/' + file
|
||||||
if not Recipe.objects.filter(file_path__iexact=path, space=monitor.space).exists() and not RecipeImport.objects.filter(file_path=path, space=monitor.space).exists():
|
if not Recipe.objects.filter(file_path__iexact=path, space=monitor.space).exists() and not RecipeImport.objects.filter(file_path=path, space=monitor.space).exists():
|
||||||
name = os.path.splitext(file)[0]
|
name = os.path.splitext(file)[0]
|
||||||
|
Loading…
Reference in New Issue
Block a user