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 requests.auth import HTTPBasicAuth
|
||||
|
||||
from recipes.settings import DEBUG
|
||||
|
||||
|
||||
class Nextcloud(Provider):
|
||||
|
||||
@ -28,15 +30,18 @@ class Nextcloud(Provider):
|
||||
def import_all(monitor):
|
||||
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)
|
||||
|
||||
try:
|
||||
files.pop(0) # remove first element because its the folder itself
|
||||
except IndexError:
|
||||
pass # folder is empty, no recipes will be imported
|
||||
if DEBUG:
|
||||
print(f'TANDOOR_PROVIDER_DEBUG file list {files}')
|
||||
|
||||
import_count = 0
|
||||
for file in files:
|
||||
if DEBUG:
|
||||
print(f'TANDOOR_PROVIDER_DEBUG importing file {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():
|
||||
name = os.path.splitext(file)[0]
|
||||
|
Loading…
Reference in New Issue
Block a user