X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=update.php;h=873928b66171a9d1676132308f40851749d55cdb;hb=9c99281f20f938701f8645aad1d25412ca6538a7;hp=f05fefcce90a8ba51b464eb67d24e156ab11b12a;hpb=bddc9788ef5c572818b19a8bfa369dc464f5482b;p=tt-rss.git diff --git a/update.php b/update.php old mode 100644 new mode 100755 index f05fefcc..873928b6 --- a/update.php +++ b/update.php @@ -1,180 +1,107 @@ +#!/usr/bin/php + // Try to lock a file in order to avoid concurrent update. + if (!$lock_handle) { + die("error: Can't create lockfile ($lock_filename). ". + "Maybe another update process is already running.\n"); + } - -
-" . - __("Could not find necessary schema file, need version:") . - " " . SCHEMA_VERSION . __(", found: ") . $latest_version . "
"; + purge_orphans($link, true); + + $rc = cleanup_tags($link, 14, 50000); - } else { - print "".__("Tiny Tiny RSS database is up to date.")."
"; - print ""; + _debug("Cleaned $rc cached tags."); } - return; } - - if (!$op) { - print_warning(__("Please backup your database before proceeding.")); - - print "" . T_sprintf("Your Tiny Tiny RSS database needs update to the latest version (%d to %d).", $version, $latest_version) . "
"; - - /* print "Available incremental updates:"; - - foreach (array_keys($update_versions) as $v) { - if ($v > $version) { - print " $v"; - } - } */ - - print "
"; - - print ""; - - } else if ($op == "do") { - - print "".__("Performing updates...")."
"; - - $num_updates = 0; - - foreach (array_keys($update_versions) as $v) { - if ($v == $version + 1) { - print "".T_sprintf("Updating to version %d...", $v)."
"; - $fp = fopen($update_versions[$v], "r"); - if ($fp) { - while (!feof($fp)) { - $query = trim(getline($fp, ";")); - if ($query != "") { - print "$query
"; - db_query($link, $query); - } - } - } - fclose($fp); - - print "".__("Checking version... "); - - $result = db_query($link, "SELECT schema_version FROM ttrss_version"); - $version = db_fetch_result($result, 0, "schema_version"); - - if ($version == $v) { - print __("OK!"); - } else { - print "".__("ERROR!").""; - return; - } - - $num_updates++; - } - } - - print "
".T_sprintf("Finished. Performed %d update(s) up to schema - version %d.", $num_updates, $version)."
"; - - print ""; + if ($op == "-cleanup-tags") { + $rc = cleanup_tags($link, 14, 50000); + print "$rc tags deleted.\n"; } - -?> - - + db_close($link); + unlink(LOCK_DIRECTORY . "/$lock_filename"); +?>