Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongo-php-library
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sinan
mongo-php-library
Commits
fcdc117c
Commit
fcdc117c
authored
Jan 12, 2017
by
Jeremy Mikola
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PHPLIB-249: GridFS stat should report modified and created timestamps
parent
eab912fe
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
1 deletion
+18
-1
StreamWrapper.php
src/GridFS/StreamWrapper.php
+7
-0
StreamWrapperFunctionalTest.php
tests/GridFS/StreamWrapperFunctionalTest.php
+11
-1
No files found.
src/GridFS/StreamWrapper.php
View file @
fcdc117c
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
namespace
MongoDB\GridFS
;
namespace
MongoDB\GridFS
;
use
MongoDB\BSON\UTCDateTime
;
use
Exception
;
use
Exception
;
/**
/**
...
@@ -152,6 +153,12 @@ class StreamWrapper
...
@@ -152,6 +153,12 @@ class StreamWrapper
$file
=
$this
->
stream
->
getFile
();
$file
=
$this
->
stream
->
getFile
();
if
(
isset
(
$file
->
uploadDate
)
&&
$file
->
uploadDate
instanceof
UTCDateTime
)
{
$timestamp
=
$file
->
uploadDate
->
toDateTime
()
->
getTimestamp
();
$stat
[
9
]
=
$stat
[
'mtime'
]
=
$timestamp
;
$stat
[
10
]
=
$stat
[
'ctime'
]
=
$timestamp
;
}
if
(
isset
(
$file
->
chunkSize
)
&&
is_integer
(
$file
->
chunkSize
))
{
if
(
isset
(
$file
->
chunkSize
)
&&
is_integer
(
$file
->
chunkSize
))
{
$stat
[
11
]
=
$stat
[
'blksize'
]
=
$file
->
chunkSize
;
$stat
[
11
]
=
$stat
[
'blksize'
]
=
$file
->
chunkSize
;
}
}
...
...
tests/GridFS/StreamWrapperFunctionalTest.php
View file @
fcdc117c
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
namespace
MongoDB\Tests\GridFS
;
namespace
MongoDB\Tests\GridFS
;
use
MongoDB\BSON\Binary
;
use
MongoDB\BSON\Binary
;
use
MongoDB\BSON\UTCDateTime
;
/**
/**
* Functional tests for the internal StreamWrapper class.
* Functional tests for the internal StreamWrapper class.
...
@@ -14,7 +15,7 @@ class StreamWrapperFunctionalTest extends FunctionalTestCase
...
@@ -14,7 +15,7 @@ class StreamWrapperFunctionalTest extends FunctionalTestCase
parent
::
setUp
();
parent
::
setUp
();
$this
->
filesCollection
->
insertMany
([
$this
->
filesCollection
->
insertMany
([
[
'_id'
=>
'length-10'
,
'length'
=>
10
,
'chunkSize'
=>
4
],
[
'_id'
=>
'length-10'
,
'length'
=>
10
,
'chunkSize'
=>
4
,
'uploadDate'
=>
new
UTCDateTime
(
'1484202200000'
)
],
]);
]);
$this
->
chunksCollection
->
insertMany
([
$this
->
chunksCollection
->
insertMany
([
...
@@ -58,6 +59,10 @@ class StreamWrapperFunctionalTest extends FunctionalTestCase
...
@@ -58,6 +59,10 @@ class StreamWrapperFunctionalTest extends FunctionalTestCase
$this
->
assertSame
(
0100444
,
$stat
[
'mode'
]);
$this
->
assertSame
(
0100444
,
$stat
[
'mode'
]);
$this
->
assertSame
(
10
,
$stat
[
7
]);
$this
->
assertSame
(
10
,
$stat
[
7
]);
$this
->
assertSame
(
10
,
$stat
[
'size'
]);
$this
->
assertSame
(
10
,
$stat
[
'size'
]);
$this
->
assertSame
(
1484202200
,
$stat
[
9
]);
$this
->
assertSame
(
1484202200
,
$stat
[
'mtime'
]);
$this
->
assertSame
(
1484202200
,
$stat
[
10
]);
$this
->
assertSame
(
1484202200
,
$stat
[
'ctime'
]);
$this
->
assertSame
(
4
,
$stat
[
11
]);
$this
->
assertSame
(
4
,
$stat
[
11
]);
$this
->
assertSame
(
4
,
$stat
[
'blksize'
]);
$this
->
assertSame
(
4
,
$stat
[
'blksize'
]);
}
}
...
@@ -99,6 +104,7 @@ class StreamWrapperFunctionalTest extends FunctionalTestCase
...
@@ -99,6 +104,7 @@ class StreamWrapperFunctionalTest extends FunctionalTestCase
public
function
testWritableStreamStat
()
public
function
testWritableStreamStat
()
{
{
$currentTimestamp
=
time
();
$stream
=
$this
->
bucket
->
openUploadStream
(
'filename'
,
[
'chunkSizeBytes'
=>
1024
]);
$stream
=
$this
->
bucket
->
openUploadStream
(
'filename'
,
[
'chunkSizeBytes'
=>
1024
]);
$stat
=
fstat
(
$stream
);
$stat
=
fstat
(
$stream
);
...
@@ -106,6 +112,10 @@ class StreamWrapperFunctionalTest extends FunctionalTestCase
...
@@ -106,6 +112,10 @@ class StreamWrapperFunctionalTest extends FunctionalTestCase
$this
->
assertSame
(
0100222
,
$stat
[
'mode'
]);
$this
->
assertSame
(
0100222
,
$stat
[
'mode'
]);
$this
->
assertSame
(
0
,
$stat
[
7
]);
$this
->
assertSame
(
0
,
$stat
[
7
]);
$this
->
assertSame
(
0
,
$stat
[
'size'
]);
$this
->
assertSame
(
0
,
$stat
[
'size'
]);
$this
->
assertGreaterThanOrEqual
(
$currentTimestamp
,
$stat
[
9
]);
$this
->
assertGreaterThanOrEqual
(
$currentTimestamp
,
$stat
[
'mtime'
]);
$this
->
assertGreaterThanOrEqual
(
$currentTimestamp
,
$stat
[
10
]);
$this
->
assertGreaterThanOrEqual
(
$currentTimestamp
,
$stat
[
'ctime'
]);
$this
->
assertSame
(
1024
,
$stat
[
11
]);
$this
->
assertSame
(
1024
,
$stat
[
11
]);
$this
->
assertSame
(
1024
,
$stat
[
'blksize'
]);
$this
->
assertSame
(
1024
,
$stat
[
'blksize'
]);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment