Skip to content
This repository has been archived by the owner on Jan 20, 2023. It is now read-only.

Commit

Permalink
Merge branch 'main' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
Endermanbugzjfc committed Oct 20, 2020
2 parents 5409521 + 19ac5a6 commit b46b9a9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
8 changes: 4 additions & 4 deletions src/Endermanbugzjfc/BackupMe/BackupArchiveAsyncTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
declare(strict_types=1);
namespace Endermanbugzjfc\BackupMe;

use pocketmine\{Server, utils\TextFormat as TF};
use pocketmine\{Server, Player, utils\TextFormat as TF};

use Endermanbugzjfc\BackupMe\libs\Inmarelibero\GitIgnoreChecker\GitIgnoreChecker;

Expand Down Expand Up @@ -83,7 +83,7 @@ public function onRun() : void {
break;

default:
$this->setResult(self::RESULT_CANNOT_CREATE_ACHIVE_FILE, Utils::serializeException(new \InvalidArgumentException('Unknown backup archiver format ID "' . $this->format . '"')));
// $this->setResult(self::RESULT_CANNOT_CREATE_ACHIVE_FILE, Utils::serializeException(new \InvalidArgumentException('Unknown backup archiver format ID "' . $this->format . '"')));
return;
break;
}
Expand Down Expand Up @@ -190,12 +190,12 @@ public function onProgressUpdate(Server $server, $progress) : void {
$e = $this->fetchLocal();
switch ((int)$progress[0]) {
case self::PROGRESS_FILE_ADDED:
if (($e instanceof events\BackupRequestByCommandEvent) and !is_null($e->getSender())) $e->getSender()->sendPopup(TF::BOLD . TF::GREEN . "File added: \n" . TF::RESET . TF::GOLD . (string)$progress[1]);
if (($e instanceof events\BackupRequestByCommandEvent) and ($e->getSender() instanceof Player)) $e->getSender()->sendPopup(TF::BOLD . TF::GREEN . "File added: \n" . TF::RESET . TF::GOLD . (string)$progress[1]);
else $e->debug('Added file "' . (string)$progress[1] . '"');
break;

case self::PROGRESS_FILE_IGNORED:
if (($e instanceof events\BackupRequestByCommandEvent) and !is_null($e->getSender())) $e->getSender()->sendPopup(TF::BOLD . TF::RED . "File ignored: \n" . TF::RESET . TF::GOLD . (string)$progress[1]);
if (($e instanceof events\BackupRequestByCommandEvent) and ($e->getSender() instanceof Player)) $e->getSender()->sendPopup(TF::BOLD . TF::RED . "File ignored: \n" . TF::RESET . TF::GOLD . (string)$progress[1]);
else $e->debug('File "' . (string)$progress[1] . '" was matching one or more rules inside the backup ignore file');
break;

Expand Down
17 changes: 10 additions & 7 deletions src/Endermanbugzjfc/BackupMe/BackupRequestListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ class BackupRequestListener implements \pocketmine\event\Listener {

protected $main;
protected $checker;
protected $source;
protected $dest;
protected $source = null;
protected $dest = null;
protected $name = 'backup-{y}-{m}-{d} {h}-{i}-{s}.{format}';
protected $format = self::ARCHIVER_ZIP;
protected $ignorediskspace = false;
Expand All @@ -59,7 +59,6 @@ public function request(events\BackupRequest $e) : void {
if (($free = (int)disk_free_space($this->dest)) < ($takes = disk_total_space($this->source) - (int)disk_free_space($this->source))) {
$log->emergency('Disk space is not enough for a backup (' . round($takes / 1024 / 1024 / 1024, 2) . ' GB' . ' out of ' . round($free / 1024 / 1024 / 1024, 2) . ' GB)');
if (!$this->doIgnoreDiskSpace()) {
$log->critical('Abort backup task due to the lacking of disk space');
(new events\BackupAbortEvent($e, events\BackupAbortEvent::REASON_DISK_SPACE_LACK))->call();
return;
}
Expand All @@ -84,14 +83,18 @@ public function stop(events\BackupStopEvent $e) : void {

if ($e instanceof events\BackupAbortEvent) {
switch ($e->getReason()) {
case events\BackupAbortEvent::REASON_COMPRESS_FAILED:
/*case $e::REASON_COMPRESS_FAILED:
$log->critical('>> !BACKUP FAILURED! << Exception encounted when compressing the backup archive file');
if (($ero = $e->getException()) instanceof \Throwable) $log->logException($ero);
break;
case events\BackupAbortEvent::REASON_CANNOT_CREATE_ACHIVE_FILE:
case $e::REASON_CANNOT_CREATE_ACHIVE_FILE:
$log->emergency('>> !BACKUP FAILURED! << Exception encounted when creating the backup archive file');
if (($ero = $e->getException()) instanceof \Throwable) $log->logException($ero);
break;*/

case $e::REASON_DISK_SPACE_LACK:
$log->critical('Abort backup task due to the lacking of disk space');
break;
}
return;
Expand All @@ -102,11 +105,11 @@ public function stop(events\BackupStopEvent $e) : void {
$log->debug('File checker resumed');
}

protected function pauseChecker() : void {
protected function pauseChecker() {
$this->checker->pause();
}

protected function resumeChecker() : void {
protected function resumeChecker() {
$this->checker->resume();
}

Expand Down

1 comment on commit b46b9a9

@JaxkDev
Copy link

@JaxkDev JaxkDev commented on b46b9a9 Nov 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dear @Endermanbugzjfc,

I regret to inform you that your plugin "BackupMe" (v1.0.2 submitted on 2020-10-20T17:20:34.000Z) has been rejected.

There is a massive amount of useless messages being outputted, please clean your output.
B3 — No useless messages in startup/shutdown:

Plugins must not output unnecessary status messages like "I have been enabled", "Author: Xxx", etc., unless the plugin startup/shutdown takes really much time (more than 1 second) such that the user may become impatient. See https://forums.pmmp.io/threads/clean-up-our-consoles.5656/

Please resolve these issues and submit the plugin again.

This comment is posted here because this is the last commit when the released build was created.

Please sign in to comment.