浏览代码

added some more checks to upgrade function

causefx 7 年之前
父节点
当前提交
92854a7e9e
共有 3 个文件被更改,包括 14 次插入4 次删除
  1. 4 4
      api/functions/api-functions.php
  2. 4 0
      api/functions/update-functions.php
  3. 6 0
      api/functions/upgrade-functions.php

+ 4 - 4
api/functions/api-functions.php

@@ -291,19 +291,19 @@ function updateDB($oldVerNum = false)
 						copy($GLOBALS['dbLocation'] . $migrationDB, $GLOBALS['dbLocation'] . $GLOBALS['dbName']);
 						@unlink($GLOBALS['dbLocation'] . $migrationDB);
 						writeLog('success', 'Update Function -  Migrated Old Info to new Database', 'Database');
-						unlink($tempLock);
+						@unlink($tempLock);
 						return true;
 					}
 				}
-				unlink($tempLock);
+				@unlink($tempLock);
 				return false;
 			} catch (Dibi\Exception $e) {
 				writeLog('error', 'Update Function -  Error [' . $e . ']', 'Database');
-				unlink($tempLock);
+				@unlink($tempLock);
 				return false;
 			}
 		}
-		unlink($tempLock);
+		@unlink($tempLock);
 		return false;
 	}
 	return false;

+ 4 - 0
api/functions/update-functions.php

@@ -32,6 +32,10 @@ function upgradeInstall($branch = 'v2-master', $stage)
 		case '3':
 			if (rcopy($source, $destination)) {
 				writeLog('success', 'Update Function -  Overwrited Files using Updated Files from Branch: ' . $branch, $GLOBALS['organizrUser']['username']);
+				$updateComplete = $GLOBALS['dbLocation'] . 'completed.txt';
+				if (!file_exists($updateComplete)) {
+					touch($updateComplete);
+				}
 				return true;
 			} else {
 				writeLog('error', 'Update Function -  Overwrite Failed for Branch: ' . $branch, $GLOBALS['organizrUser']['username']);

+ 6 - 0
api/functions/upgrade-functions.php

@@ -3,6 +3,12 @@ function upgradeCheck()
 {
 	if (file_exists('config' . DIRECTORY_SEPARATOR . 'config.php')) {
 		$tempLock = $GLOBALS['dbLocation'] . 'DBLOCK.txt';
+		$updateComplete = $GLOBALS['dbLocation'] . 'completed.txt';
+		$cleanup = dirname(__DIR__, 2) . DIRECTORY_SEPARATOR . "upgrade" . DIRECTORY_SEPARATOR;
+		if (file_exists($updateComplete)) {
+			@unlink($updateComplete);
+			@rrmdir($cleanup);
+		}
 		if (file_exists($tempLock)) {
 			die('upgrading');
 		}