Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
our_own_cloud_project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
die_coolen_jungs
our_own_cloud_project
Commits
6e6a131b
Commit
6e6a131b
authored
11 years ago
by
Vincent Petry
Browse files
Options
Downloads
Plain Diff
Merge pull request #7696 from owncloud/chunk-remainingspacefix
Fixed chunking and insufficient storage check
parents
27eff1ac
4033eba3
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/private/connector/sabre/quotaplugin.php
+11
-0
11 additions, 0 deletions
lib/private/connector/sabre/quotaplugin.php
lib/private/filechunking.php
+37
-3
37 additions, 3 deletions
lib/private/filechunking.php
with
48 additions
and
3 deletions
lib/private/connector/sabre/quotaplugin.php
+
11
−
0
View file @
6e6a131b
...
...
@@ -56,8 +56,19 @@ class OC_Connector_Sabre_QuotaPlugin extends Sabre_DAV_ServerPlugin {
$uri
=
'/'
.
$uri
;
}
list
(
$parentUri
,
$newName
)
=
Sabre_DAV_URLUtil
::
splitPath
(
$uri
);
$req
=
$this
->
server
->
httpRequest
;
if
(
$req
->
getHeader
(
'OC-Chunked'
))
{
$info
=
OC_FileChunking
::
decodeName
(
$newName
);
$chunkHandler
=
new
OC_FileChunking
(
$info
);
// substract the already uploaded size to see whether
// there is still enough space for the remaining chunks
$length
-=
$chunkHandler
->
getCurrentSize
();
}
$freeSpace
=
$this
->
getFreeSpace
(
$parentUri
);
if
(
$freeSpace
!==
\OC\Files\SPACE_UNKNOWN
&&
$length
>
$freeSpace
)
{
if
(
isset
(
$chunkHandler
))
{
$chunkHandler
->
cleanup
();
}
throw
new
Sabre_DAV_Exception_InsufficientStorage
();
}
}
...
...
This diff is collapsed.
Click to expand it.
lib/private/filechunking.php
+
37
−
3
View file @
6e6a131b
...
...
@@ -64,19 +64,45 @@ class OC_FileChunking {
return
$parts
==
$this
->
info
[
'chunkcount'
];
}
/**
* Assembles the chunks into the file specified by the path.
* Chunks are deleted afterwards.
*
* @param string $f target path
*
* @return assembled file size
*
* @throws \OC\InsufficientStorageException when file could not be fully
* assembled due to lack of free space
*/
public
function
assemble
(
$f
)
{
$cache
=
$this
->
getCache
();
$prefix
=
$this
->
getPrefix
();
$count
=
0
;
for
(
$i
=
0
;
$i
<
$this
->
info
[
'chunkcount'
];
$i
++
)
{
$chunk
=
$cache
->
get
(
$prefix
.
$i
);
// remove after reading to directly save space
$cache
->
remove
(
$prefix
.
$i
);
$count
+=
fwrite
(
$f
,
$chunk
);
}
$this
->
cleanup
();
return
$count
;
}
/**
* Returns the size of the chunks already present
* @return size in bytes
*/
public
function
getCurrentSize
()
{
$cache
=
$this
->
getCache
();
$prefix
=
$this
->
getPrefix
();
$total
=
0
;
for
(
$i
=
0
;
$i
<
$this
->
info
[
'chunkcount'
];
$i
++
)
{
$total
+=
$cache
->
size
(
$prefix
.
$i
);
}
return
$total
;
}
/**
* Removes all chunks which belong to this transmission
*/
...
...
@@ -128,7 +154,15 @@ class OC_FileChunking {
}
/**
* @param string $path
* Assembles the chunks into the file specified by the path.
* Also triggers the relevant hooks and proxies.
*
* @param string $path target path
*
* @return assembled file size or false if file could not be created
*
* @throws \OC\InsufficientStorageException when file could not be fully
* assembled due to lack of free space
*/
public
function
file_assemble
(
$path
)
{
$absolutePath
=
\OC\Files\Filesystem
::
normalizePath
(
\OC\Files\Filesystem
::
getView
()
->
getAbsolutePath
(
$path
));
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment