Skip to content

Commit 447f619

Browse files
committed
fix: Keep backward compatibility to nc < 33
Signed-off-by: Marcel Klehr <[email protected]>
1 parent f424307 commit 447f619

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

.github/workflows/integration_test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
matrix:
2929
php-versions: [ '8.3' ]
3030
databases: [ 'sqlite' ]
31-
server-versions: [ 'master' ]
31+
server-versions: [ 'master', 'stable32', 'stable31', 'stable30' ]
3232

3333
name: Integration test on ☁️${{ matrix.server-versions }} 🐘${{ matrix.php-versions }}
3434

appinfo/info.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ See [the nextcloud admin docs](https://docs.nextcloud.com/server/latest/admin_ma
2424
<repository type="git">https://github.com/nextcloud/llm2</repository>
2525
<screenshot>https://raw.githubusercontent.com/nextcloud/llm2/main/img/Logo.png</screenshot>
2626
<dependencies>
27-
<nextcloud min-version="33" max-version="33"/>
27+
<nextcloud min-version="30" max-version="33"/>
2828
</dependencies>
2929
<external-app>
3030
<docker-install>

lib/main.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ def log(nc, level, content):
3737
}
3838
app_enabled = Event()
3939
trigger = Event()
40-
CHECK_INTERVAL = 5 * 60
40+
CHECK_INTERVAL = 5
41+
CHECK_INTERVAL_WITH_TRIGGER = 5 * 60
4142
CHECK_INTERVAL_ON_ERROR = 10
4243

4344
@asynccontextmanager
@@ -88,15 +89,14 @@ def background_thread_task():
8889
(model, task) = task_processor_name.split(":", 1)
8990
task_type_ids.add(task)
9091

91-
trigger.clear()
9292
try:
9393
response = nc.providers.task_processing.next_task(list(provider_ids), list(task_type_ids))
9494
if not response:
95-
trigger.wait(timeout=CHECK_INTERVAL)
95+
wait_for_tasks()
9696
continue
9797
except (NextcloudException, RequestException, JSONDecodeError) as e:
9898
log(nc, LogLvl.ERROR, f"Network error fetching the next task {e}")
99-
trigger.wait(timeout=CHECK_INTERVAL_ON_ERROR)
99+
wait_for_tasks(CHECK_INTERVAL_ON_ERROR)
100100
continue
101101

102102
task = response["task"]
@@ -134,8 +134,6 @@ def background_thread_task():
134134
nc.providers.task_processing.report_result(task["id"], error_message=str(e))
135135
except (NextcloudException, RequestException) as net_err:
136136
log(nc, LogLvl.INFO, f"Network error in reporting the error: {net_err}")
137-
# if trigger has been set sinec the start of this iteration this will pass right through
138-
trigger.wait(timeout=CHECK_INTERVAL)
139137

140138

141139
def start_bg_task():
@@ -191,5 +189,14 @@ def trigger_handler(providerId: str):
191189
print('TRIGGER called')
192190
trigger.set()
193191

192+
def wait_for_tasks(interval = None):
193+
global CHECK_INTERVAL
194+
global CHECK_INTERVAL_WITH_TRIGGER
195+
actual_interval = CHECK_INTERVAL if interval is None else interval
196+
if trigger.wait(timeout=actual_interval):
197+
CHECK_INTERVAL = CHECK_INTERVAL_WITH_TRIGGER
198+
trigger.clear()
199+
200+
194201
if __name__ == "__main__":
195202
run_app("main:APP", log_level="trace")

0 commit comments

Comments
 (0)