Skip to content

Commit

Permalink
allow to store 64bit mtime
Browse files Browse the repository at this point in the history
  • Loading branch information
individual-it authored and phil-davis committed Sep 9, 2017
1 parent 342754d commit a5769c4
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
22 changes: 22 additions & 0 deletions apps/dav/appinfo/Migrations/Version20170607100912.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
namespace OCA\dav\Migrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Type;
use OCP\Migration\ISchemaMigration;

/**
* changes mtime fields to be able to store 64bit time stamps
*/
class Version20170607100912 implements ISchemaMigration {

public function changeSchema(Schema $schema, array $options) {
$prefix = $options['tablePrefix'];
$table = $schema->getTable("${prefix}filecache");
foreach ( ['mtime','storage_mtime'] as $column ) {
if ($table->getColumn($column)->getType()->getName() === Type::INTEGER) {
$table->getColumn($column)->setType(Type::getType(Type::BIGINT));
}
}
}
}
2 changes: 1 addition & 1 deletion apps/dav/appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<description>ownCloud WebDAV endpoint</description>
<licence>AGPL</licence>
<author>owncloud.org</author>
<version>0.3.0</version>
<version>0.3.1</version>
<default_enable/>
<use-migrations>true</use-migrations>
<types>
Expand Down
16 changes: 16 additions & 0 deletions apps/dav/tests/unit/Connector/Sabre/FileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,22 @@ public function legalMtimeProvider() {
'HTTP_X_OC_MTIME' => -34.43,
'expected result' => -34
],
"long int" => [
'HTTP_X_OC_MTIME' => PHP_INT_MAX,
'expected result' => PHP_INT_MAX
],
"too long int" => [
'HTTP_X_OC_MTIME' => PHP_INT_MAX + 1,
'expected result' => PHP_INT_MAX
],
"long negative int" => [
'HTTP_X_OC_MTIME' => PHP_INT_MAX * - 1,
'expected result' => (PHP_INT_MAX * - 1)
],
"too long negative int" => [
'HTTP_X_OC_MTIME' => (PHP_INT_MAX * - 1) - 1,
'expected result' => (PHP_INT_MAX * - 1)
],
];
}

Expand Down

0 comments on commit a5769c4

Please sign in to comment.