2015-01-12 17:22:02 +03:00
|
|
|
<?php
|
|
|
|
/**
|
2015-10-05 21:54:56 +03:00
|
|
|
* @author Joas Schilling <nickvergessen@owncloud.com>
|
2015-03-26 13:44:34 +03:00
|
|
|
* @author Morris Jobke <hey@morrisjobke.de>
|
|
|
|
* @author Thomas Müller <thomas.mueller@tmit.eu>
|
|
|
|
*
|
|
|
|
* @copyright Copyright (c) 2015, ownCloud, Inc.
|
|
|
|
* @license AGPL-3.0
|
|
|
|
*
|
|
|
|
* This code is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License, version 3,
|
|
|
|
* as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3,
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
|
|
|
*
|
2015-01-12 17:22:02 +03:00
|
|
|
*/
|
2015-02-26 13:37:37 +03:00
|
|
|
|
2015-01-12 17:22:02 +03:00
|
|
|
namespace OC\Repair;
|
|
|
|
|
|
|
|
use OC\Hooks\BasicEmitter;
|
|
|
|
|
|
|
|
class FillETags extends BasicEmitter implements \OC\RepairStep {
|
|
|
|
|
2015-07-06 13:34:19 +03:00
|
|
|
/** @var \OCP\IDBConnection */
|
2015-01-12 17:22:02 +03:00
|
|
|
protected $connection;
|
|
|
|
|
|
|
|
/**
|
2015-07-06 13:34:19 +03:00
|
|
|
* @param \OCP\IDBConnection $connection
|
2015-01-12 17:22:02 +03:00
|
|
|
*/
|
|
|
|
public function __construct($connection) {
|
|
|
|
$this->connection = $connection;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getName() {
|
|
|
|
return 'Generate ETags for file where no ETag is present.';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function run() {
|
2015-07-06 13:34:19 +03:00
|
|
|
$qb = $this->connection->getQueryBuilder();
|
2015-08-10 17:21:41 +03:00
|
|
|
$qb->update('filecache')
|
2015-07-07 23:08:21 +03:00
|
|
|
->set('etag', $qb->expr()->literal('xxx'))
|
|
|
|
->where($qb->expr()->eq('etag', $qb->expr()->literal('')))
|
|
|
|
->orWhere($qb->expr()->isNull('etag'));
|
2015-01-12 17:22:02 +03:00
|
|
|
|
|
|
|
$result = $qb->execute();
|
|
|
|
$this->emit('\OC\Repair', 'info', array("ETags have been fixed for $result files/folders."));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|