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
b7d8da87
Commit
b7d8da87
authored
11 years ago
by
Sam Tuke
Browse files
Options
Downloads
Patches
Plain Diff
Development snapshot
working on stream handling (large files) in Util->encryptAll()
parent
c6bfc731
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
apps/files_encryption/lib/keymanager.php
+2
-1
2 additions, 1 deletion
apps/files_encryption/lib/keymanager.php
apps/files_encryption/lib/proxy.php
+0
-1
0 additions, 1 deletion
apps/files_encryption/lib/proxy.php
apps/files_encryption/lib/util.php
+26
-24
26 additions, 24 deletions
apps/files_encryption/lib/util.php
with
28 additions
and
26 deletions
apps/files_encryption/lib/keymanager.php
+
2
−
1
View file @
b7d8da87
...
...
@@ -106,6 +106,7 @@ class Keymanager {
*/
public
static
function
setFileKey
(
\OC_FilesystemView
$view
,
$path
,
$userId
,
$catfile
)
{
$proxyStatus
=
\OC_FileProxy
::
$enabled
;
\OC_FileProxy
::
$enabled
=
false
;
//here we need the currently logged in user, while userId can be a different user
...
...
@@ -129,7 +130,7 @@ class Keymanager {
$result
=
$view
->
file_put_contents
(
$basePath
.
'/'
.
$targetPath
.
'.key'
,
$catfile
);
\OC_FileProxy
::
$enabled
=
true
;
\OC_FileProxy
::
$enabled
=
$proxyStatus
;
return
$result
;
...
...
This diff is collapsed.
Click to expand it.
apps/files_encryption/lib/proxy.php
+
0
−
1
View file @
b7d8da87
...
...
@@ -142,7 +142,6 @@ class Proxy extends \OC_FileProxy {
$multiEncrypted
=
Crypt
::
multiKeyEncrypt
(
$plainKey
,
$publicKeys
);
// Save sharekeys to user folders
Keymanager
::
setShareKeys
(
$rootView
,
$filePath
,
$multiEncrypted
[
'keys'
]
);
// Set encrypted keyfile as common varname
...
...
This diff is collapsed.
Click to expand it.
apps/files_encryption/lib/util.php
+
26
−
24
View file @
b7d8da87
...
...
@@ -500,37 +500,39 @@ class Util {
// Encrypt unencrypted files
foreach
(
$found
[
'plain'
]
as
$plainFile
)
{
// Open plain file handle
// Open enc file handle
// Read plain file in chunks
//relative to data/<user>/file
$relPath
=
$plainFile
[
'path'
];
//relative to /data
$rawPath
=
$this
->
userId
.
'/files/'
.
$plainFile
[
'path'
];
// Open handle with for binary reading
$plainHandle
=
$this
->
view
->
fopen
(
$rawPath
,
'rb'
);
// Open handle with for binary writing
$encHandle
=
fopen
(
'crypt://'
.
$relPath
.
'.tmp'
,
'wb'
);
// Overwrite the existing file with the encrypted one
//$this->view->file_put_contents( $plainFile['path'], $encrypted['data'] );
$size
=
stream_copy_to_stream
(
$plainHandle
,
$encHandle
);
$this
->
view
->
rename
(
$rawPath
.
'.tmp'
,
$rawPath
);
// Fetch the key that has just been set/updated by the stream
//$encKey = Keymanager::getFileKey( $this->view, $this->userId, $relPath );
// Open plain file handle for binary reading
$plainHandle1
=
$this
->
view
->
fopen
(
$rawPath
,
'rb'
);
// 2nd handle for moving plain file - view->rename() doesn't work, this is a workaround
$plainHandle2
=
$this
->
view
->
fopen
(
$rawPath
.
'.plaintmp'
,
'wb'
);
// Move plain file to a temporary location
stream_copy_to_stream
(
$plainHandle1
,
$plainHandle2
);
// Close access to original file
// $this->view->fclose( $plainHandle1 ); // not implemented in view{}
// Delete original plain file so we can rename enc file later
$this
->
view
->
unlink
(
$rawPath
);
// Open enc file handle for binary writing, with same filename as original plain file
$encHandle
=
fopen
(
'crypt://'
.
$relPath
,
'wb'
);
// Save data from plain stream to new encrypted file via enc stream
// NOTE: Stream{} will be invoked for handling
// the encryption, and should handle all keys
// and their generation etc. automatically
$size
=
stream_copy_to_stream
(
$plainHandle2
,
$encHandle
);
//
Save key
file
//Keymanager::setFileKey(
$this->view
,
$r
el
Path
, $this->userId, $encKey
);
//
Delete temporary plain copy of
file
$this
->
view
->
unlink
(
$r
aw
Path
.
'.plaintmp'
);
// Add the file to the cache
\OC\Files\Filesystem
::
putFileInfo
(
$plainFile
[
'path'
],
array
(
'encrypted'
=>
true
,
'size'
=>
$size
),
''
);
...
...
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