Skip to content

Commit

Permalink
Treat domain as missing if file is empty https://forum.virtualmin.com…
Browse files Browse the repository at this point in the history
  • Loading branch information
jcameron committed Feb 6, 2022
1 parent 8edca10 commit faaa880
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions restore-domain.pl
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,10 @@ package virtual_server;
}
foreach $dname (@rdoms) {
local $dinfo = &get_domain_by("dom", $dname);
if (!$dinfo->{'id'}) {
# File is actually empty!
$dinfo = undef;
}
if ($dname eq "virtualmin") {
$got_vbs = 1;
}
Expand Down
4 changes: 4 additions & 0 deletions restore.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ if ($in{'confirm'}) {
next;
}
local $dinfo = &get_domain_by("dom", $d);
if (!$dinfo->{'id'}) {
# File is actually empty!
$dinfo = undef;
}
if ($dinfo) {
&can_edit_domain($dinfo) ||
&error(&text('restore_ecannotdom',
Expand Down

12 comments on commit faaa880

@iliajie
Copy link
Collaborator

@iliajie iliajie commented on faaa880 Feb 6, 2022

Choose a reason for hiding this comment

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

That didn't work, although this PR works for me - #367

@jcameron
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Why didn't the original work? On your test system, as the domain file entirely empty, or was it just missing some details?

@iliajie
Copy link
Collaborator

@iliajie iliajie commented on faaa880 Feb 6, 2022

Choose a reason for hiding this comment

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

I made it empty. But $dinfo always contained all details. Is it coming from a backup?

@jcameron
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In this code, it's only coming from the local files.

@iliajie
Copy link
Collaborator

@iliajie iliajie commented on faaa880 Feb 6, 2022

Choose a reason for hiding this comment

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

But it does not seem like it is? It didn't work for me..

@iliajie
Copy link
Collaborator

@iliajie iliajie commented on faaa880 Feb 6, 2022

Choose a reason for hiding this comment

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

Also, perhaps it's connected - when I restore only with virtualmin feature, and with --fix switch, I expect the domain config file overwritten with one in backup. It wasn't happening for me.. The original domain file was kept (it wasn't corrupted though)?

@iliajie
Copy link
Collaborator

@iliajie iliajie commented on faaa880 Feb 7, 2022

Choose a reason for hiding this comment

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

Solved. Ref.

@iliajie
Copy link
Collaborator

Choose a reason for hiding this comment

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

Jamie, can you double check please if we still need this?

@jcameron
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I can't see any harm in keeping it ..

@iliajie
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you mean merging this PR?

@jcameron
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This PR is merged already though, right?

@iliajie
Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh, yes, right!

Please sign in to comment.