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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
die_coolen_jungs
our_own_cloud_project
Commits
5ce4149e
Commit
5ce4149e
authored
12 years ago
by
Björn Schießle
Browse files
Options
Downloads
Patches
Plain Diff
fix first time encryption after app was enabled
parent
49113058
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
apps/files_encryption/lib/util.php
+12
-23
12 additions, 23 deletions
apps/files_encryption/lib/util.php
with
12 additions
and
23 deletions
apps/files_encryption/lib/util.php
+
12
−
23
View file @
5ce4149e
...
@@ -421,7 +421,7 @@ class Util
...
@@ -421,7 +421,7 @@ class Util
// If the file uses old
// If the file uses old
// encryption system
// encryption system
}
elseif
(
Crypt
::
isLegacyEncryptedContent
(
$
this
->
tail
(
$filePath
,
3
)
,
$relPath
)
)
{
}
elseif
(
Crypt
::
isLegacyEncryptedContent
(
$
data
,
$relPath
)
)
{
$found
[
'legacy'
][]
=
array
(
'name'
=>
$file
,
'path'
=>
$filePath
);
$found
[
'legacy'
][]
=
array
(
'name'
=>
$file
,
'path'
=>
$filePath
);
...
@@ -672,39 +672,28 @@ class Util
...
@@ -672,39 +672,28 @@ class Util
$relPath
=
$plainFile
[
'path'
];
$relPath
=
$plainFile
[
'path'
];
//relative to /data
//relative to /data
$rawPath
=
$this
->
userId
.
'/files/'
.
$plainFile
[
'path'
];
$rawPath
=
'/'
.
$this
->
userId
.
'/files/'
.
$plainFile
[
'path'
];
// Open plain file handle for binary reading
// Open plain file handle for binary reading
$plainHandle
1
=
$this
->
view
->
fopen
(
$rawPath
,
'rb'
);
$plainHandle
=
$this
->
view
->
fopen
(
$rawPath
,
'rb'
);
//
2nd handle for moving plain file - view->rename() doesn't work, this is a workaround
//
Open enc file handle for binary writing, with same filename as original plain file
$
plain
Handle
2
=
$this
->
view
->
fopen
(
$rawPath
.
'.plain
tmp'
,
'wb'
);
$
enc
Handle
=
fopen
(
'crypt://'
.
$relPath
.
'.
tmp'
,
'wb'
);
// Move plain file to a temporary location
// Move plain file to a temporary location
stream_copy_to_stream
(
$plainHandle1
,
$plainHandle2
);
$size
=
stream_copy_to_stream
(
$plainHandle
,
$encHandle
);
// 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
fclose
(
$encHandle
);
$encHandle
=
fopen
(
'crypt://'
.
$relPath
,
'wb'
);
// Save data from plain stream to new encrypted file via enc stream
$fakeRoot
=
$this
->
view
->
getRoot
();
// NOTE: Stream{} will be invoked for handling
$this
->
view
->
chroot
(
'/'
.
$this
->
userId
.
'/files'
);
// the encryption, and should handle all keys
// and their generation etc. automatically
stream_copy_to_stream
(
$plainHandle2
,
$encHandle
);
// get file size
$this
->
view
->
rename
(
$relPath
.
'.tmp'
,
$relPath
);
$size
=
$this
->
view
->
filesize
(
$rawPath
.
'.plaintmp'
);
// Delete temporary plain copy of file
$this
->
view
->
chroot
(
$fakeRoot
);
$this
->
view
->
unlink
(
$rawPath
.
'.plaintmp'
);
// Add the file to the cache
// Add the file to the cache
\OC\Files\Filesystem
::
putFileInfo
(
$
plainFile
[
'p
ath
'
]
,
array
(
'encrypted'
=>
true
,
'size'
=>
$size
,
'unencrypted_size'
=>
$size
)
);
\OC\Files\Filesystem
::
putFileInfo
(
$
relP
ath
,
array
(
'encrypted'
=>
true
,
'size'
=>
$size
,
'unencrypted_size'
=>
$size
)
);
}
}
// Encrypt legacy encrypted files
// Encrypt legacy encrypted files
...
...
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