diff --git a/includes/sql-schema/update.php b/includes/sql-schema/update.php index 23038e5fc..c07909845 100644 --- a/includes/sql-schema/update.php +++ b/includes/sql-schema/update.php @@ -31,15 +31,6 @@ if (!isset($debug)) { } } -if (!dbGetLock('schema_update')) { - echo "Schema update already in progress. Exiting\n"; - exit(1); -} //end if - -do { - sleep(1); -} while (@dbFetchCell('SELECT COUNT(*) FROM `devices` WHERE NOT IS_FREE_LOCK(CONCAT("polling.", device_id)) OR NOT IS_FREE_LOCK(CONCAT("queued.", device_id)) OR NOT IS_FREE_LOCK(CONCAT("discovering.", device_id))') > 0); - $insert = 0; if ($db_rev = @dbFetchCell('SELECT version FROM `dbSchema` ORDER BY version DESC LIMIT 1')) { @@ -100,6 +91,15 @@ if (explode('.', max($filelist), 2) <= $db_rev) { exit(0); } +if (!dbGetLock('schema_update')) { + echo "Schema update already in progress. Exiting\n"; + exit(1); +} //end if + +do { + sleep(1); +} while (@dbFetchCell('SELECT COUNT(*) FROM `devices` WHERE NOT IS_FREE_LOCK(CONCAT("polling.", device_id)) OR NOT IS_FREE_LOCK(CONCAT("queued.", device_id)) OR NOT IS_FREE_LOCK(CONCAT("discovering.", device_id))') > 0); + foreach ($filelist as $file) { list($filename,$extension) = explode('.', $file, 2); if ($filename > $db_rev) {