From 0f1cd9662d2d9645b5f89fad86c72727cf78f862 Mon Sep 17 00:00:00 2001 From: j Date: Thu, 18 Feb 2016 19:22:53 +0530 Subject: [PATCH] dont open to many sessions --- oml/item/scan.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/oml/item/scan.py b/oml/item/scan.py index 395e6d1..fb2cc35 100644 --- a/oml/item/scan.py +++ b/oml/item/scan.py @@ -126,12 +126,12 @@ def run_scan(): remove_missing(books) added = 0 - for f in ox.sorted_strings(books): - if state.shutdown: - return - if os.path.exists(f): - id = media.get_id(f) - with db.session(): + with db.session(): + for f in ox.sorted_strings(books): + if state.shutdown: + break + if os.path.exists(f): + id = media.get_id(f) file = File.get(id) if not file: file = add_file(id, f, prefix, f)