Skip to content

Commit

Permalink
Bugfix: status table was not logging executed tasks, because the acti…
Browse files Browse the repository at this point in the history
…on column definition was wrong
  • Loading branch information
gboudreau committed Sep 12, 2020
1 parent ed067b4 commit 349f427
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
9 changes: 9 additions & 0 deletions includes/DB.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,10 @@ private static function migrate() {
DB::migrate_16_larger_action();
Settings::set('db_version', 16);
}
if ($db_version < 17) {
DB::migrate_17_status_action();
Settings::set('db_version', 17);
}
}

// Migration #1 (complete = frozen|thawed)
Expand Down Expand Up @@ -492,6 +496,11 @@ private static function migrate_16_larger_action() {
DB::execute($query);
}

private static function migrate_17_status_action() {
$query = "ALTER TABLE `status` CHANGE `action` `action` varchar(16) CHARACTER SET latin1 COLLATE latin1_general_ci DEFAULT NULL";
DB::execute($query);
}

public static function repairTables() {
if (Log::actionIs(ACTION_DAEMON)) {
Log::info("Checking MySQL tables...");
Expand Down
3 changes: 2 additions & 1 deletion includes/Log.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ private static function _log($local_log_level, $text, $event_code) {
}
static::$last_log = $text;
} catch (\Exception $ex) {
error_log("[Greyhole] Error logging status in database: " . $ex->getMessage());
$text .= " [ERROR logging status in database: " . $ex->getMessage() . "]";
$local_log_level = self::ERROR;
}
}
if ($local_log_level > self::$level) {
Expand Down
5 changes: 3 additions & 2 deletions schema-mysql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ PRIMARY KEY (`name`)

INSERT INTO `settings` (`name`, `value`) VALUES ('last_read_log_smbd_line', '0');
INSERT INTO `settings` (`name`, `value`) VALUES ('last_OOS_notification', '0');
INSERT INTO `settings` (`name`, `value`) VALUES ('db_version', '16');
INSERT INTO `settings` (`name`, `value`) VALUES ('db_version', '17');

CREATE TABLE `tasks` (
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
Expand Down Expand Up @@ -52,7 +52,8 @@ PRIMARY KEY (`id`)
CREATE TABLE `status` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`date_time` timestamp NOT NULL DEFAULT current_timestamp(),
`action` enum('initialize','unknown','daemon','pause','resume','fsck','balance','stats','status','logs','trash','queue','iostat','getuid','worker','symlinks','replace','for','gone','going','thaw','debug','metadata','share','check_pool','sleep','read_smb_spool','fsck_file') DEFAULT NULL,
`action` varchar(16) CHARACTER SET latin1 COLLATE latin1_general_ci DEFAULT NULL,
-- `action` enum('initialize','unknown','daemon','pause','resume','fsck','balance','stats','status','logs','trash','queue','iostat','getuid','worker','symlinks','replace','for','gone','going','thaw','debug','metadata','share','check_pool','sleep','read_smb_spool','fsck_file') DEFAULT NULL,
`log` text NOT NULL,
UNIQUE KEY `id` (`id`)
) ENGINE = MYISAM DEFAULT CHARSET=utf8;

0 comments on commit 349f427

Please sign in to comment.