| | 105 | }); |
|---|
| | 106 | |
|---|
| | 107 | MogileFS::register_worker_command( 'filepaths_enable', sub { |
|---|
| | 108 | # get parameters |
|---|
| | 109 | my MogileFS::Worker::Query $self = shift; |
|---|
| | 110 | my $args = shift; |
|---|
| | 111 | |
|---|
| | 112 | # verify domain firstly |
|---|
| | 113 | my $dmid = $self->check_domain($args) |
|---|
| | 114 | or return $self->err_line('domain_not_found'); |
|---|
| | 115 | |
|---|
| | 116 | my $dbh = Mgd::get_dbh(); |
|---|
| | 117 | return undef unless $dbh; |
|---|
| | 118 | |
|---|
| | 119 | $dbh->do("REPLACE INTO plugin_filepaths_domains (dmid) VALUES (?)", undef, $dmid); |
|---|
| | 120 | |
|---|
| | 121 | return $self->err_line('unable_to_enable', "Unable to enable the filepaths plugin: " . $dbh->errstr) |
|---|
| | 122 | if $dbh->err; |
|---|
| | 123 | |
|---|
| | 124 | return $self->ok_line; |
|---|
| | 125 | }); |
|---|
| | 126 | |
|---|
| | 127 | MogileFS::register_worker_command( 'filepaths_disable', sub { |
|---|
| | 128 | # get parameters |
|---|
| | 129 | my MogileFS::Worker::Query $self = shift; |
|---|
| | 130 | my $args = shift; |
|---|
| | 131 | |
|---|
| | 132 | # verify domain firstly |
|---|
| | 133 | my $dmid = $self->check_domain($args) |
|---|
| | 134 | or return $self->err_line('domain_not_found'); |
|---|
| | 135 | |
|---|
| | 136 | my $dbh = Mgd::get_dbh(); |
|---|
| | 137 | return undef unless $dbh; |
|---|
| | 138 | |
|---|
| | 139 | $dbh->do("DELETE FROM plugin_filepaths_domains WHERE dmid = ?", undef, $dmid); |
|---|
| | 140 | |
|---|
| | 141 | return $self->err_line('unable_to_disable', "Unable to enable the filepaths plugin: " . $dbh->errstr) |
|---|
| | 142 | if $dbh->err; |
|---|
| | 143 | |
|---|
| | 144 | return $self->ok_line; |
|---|