Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
rdiff-backup
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Guillaume Hervier
rdiff-backup
Commits
6d517327
Commit
6d517327
authored
Aug 22, 2018
by
Guillaume Hervier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement lazy file opening for diff generation
parent
76799c30
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
1 deletion
+28
-1
rdiff_backup/opener.py
rdiff_backup/opener.py
+25
-0
rdiff_backup/restore.py
rdiff_backup/restore.py
+3
-1
No files found.
rdiff_backup/opener.py
0 → 100644
View file @
6d517327
class
LazyFile
:
def
__init__
(
self
,
path
,
*
args
,
**
kwargs
):
self
.
path
=
path
self
.
args
=
args
self
.
kwargs
=
kwargs
self
.
file
=
None
def
read
(
self
,
length
=-
1
):
self
.
open
()
return
self
.
file
.
read
(
length
)
def
open
(
self
):
if
self
.
file
is
None
:
self
.
file
=
open
(
self
.
path
,
*
self
.
args
,
**
self
.
kwargs
)
def
close
(
self
):
if
self
.
file
is
None
:
return
None
value
=
self
.
file
.
close
()
self
.
file
=
None
return
value
def
lazy_open
(
path
,
*
args
,
**
kwargs
):
return
LazyFile
(
path
,
*
args
,
**
kwargs
)
rdiff_backup/restore.py
View file @
6d517327
...
...
@@ -24,6 +24,7 @@ from __future__ import generators
from
pool
import
Pool
as
ThreadPool
import
tempfile
,
os
,
cStringIO
,
itertools
import
static
,
rorpiter
,
FilenameMapping
,
connection
import
opener
class
RestoreError
(
Exception
):
pass
...
...
@@ -294,7 +295,8 @@ class MirrorStruct:
# a file is already there, we can create a diff
signature_vf
=
target_rorp
.
conn
.
Rdiff
.
get_signature_vf
(
target_rorp
)
target_signature
=
connection
.
VirtualFile
(
target_rorp
.
conn
,
signature_vf
)
delta_fp
=
mir_rorp
.
get_delta
(
target_signature
,
open
(
file_fp
.
name
,
'rb'
))
file_fobj
=
opener
.
lazy_open
(
file_fp
.
name
,
'rb'
)
delta_fp
=
mir_rorp
.
get_delta
(
target_signature
,
file_fobj
)
mir_rorp
.
setfile
(
delta_fp
)
else
:
# standard rdiff-backup behavior, transfer everything
...
...
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