Commit b21b5fe3 authored by eskumon's avatar eskumon
Browse files

fix(frontend): Copy screenshots after version update

    Checks if the screenshot column exists (added in the 0.5 release)
and copies local screenshot files to the database

    fixes #1218
parent 08b6c36e
...@@ -15,8 +15,9 @@ use Moose; ...@@ -15,8 +15,9 @@ use Moose;
use POSIX qw(WNOHANG); use POSIX qw(WNOHANG);
use Time::HiRes qw(gettimeofday tv_interval); use Time::HiRes qw(gettimeofday tv_interval);
use YAML; use YAML;
use MIME::Base64;
use Socket qw( inet_aton inet_ntoa ); use Socket qw( inet_aton inet_ntoa );
use Image::Magick::Q16;
no warnings "experimental::signatures"; no warnings "experimental::signatures";
use feature qw(signatures); use feature qw(signatures);
...@@ -1261,7 +1262,13 @@ sub _upgrade_tables { ...@@ -1261,7 +1262,13 @@ sub _upgrade_tables {
$self->_upgrade_table('domains','is_pool','int NOT NULL default 0'); $self->_upgrade_table('domains','is_pool','int NOT NULL default 0');
$self->_upgrade_table('domains','needs_restart','int not null default 0'); $self->_upgrade_table('domains','needs_restart','int not null default 0');
$self->_upgrade_table('domains','screenshot','BLOB');
if ($self->_upgrade_table('domains','screenshot','BLOB')) {
$self->_upgrade_screenshots();
}
$self->_upgrade_table('domains_network','allowed','int not null default 1'); $self->_upgrade_table('domains_network','allowed','int not null default 1');
$self->_upgrade_table('iptables','id_vm','int DEFAULT NULL'); $self->_upgrade_table('iptables','id_vm','int DEFAULT NULL');
...@@ -2479,6 +2486,21 @@ sub _cmd_copy_screenshot { ...@@ -2479,6 +2486,21 @@ sub _cmd_copy_screenshot {
} }
} }
sub _upgrade_screenshots() {
my $self = shift;
my $id = shift or confess "ERROR: missing argument id";
my $sth = $CONNECTOR->dbh->prepare("SELECT file_screenshot FROM domains WHERE id=?");
$sth->execute($id);
my ($file_path)= $sth->fetchrow;
my $file= new Image::Magick::Q16;
$file->Read($file_path);
$self->_data(screenshot => encode_base64($file));
}
sub _cmd_create{ sub _cmd_create{
my $self = shift; my $self = shift;
my $request = shift; my $request = shift;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment