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
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
rdiff-backup
Commits
1ef9675c
Commit
1ef9675c
authored
Jan 30, 2014
by
Mathieu Le Marec - Pasquet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
2nd patch from debian
parent
f8da1abe
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
7 deletions
+28
-7
rdiff_backup/Hardlink.py
rdiff_backup/Hardlink.py
+7
-1
rdiff_backup/compare.py
rdiff_backup/compare.py
+21
-6
No files found.
rdiff_backup/Hardlink.py
View file @
1ef9675c
...
...
@@ -95,7 +95,13 @@ def rorp_eq(src_rorp, dest_rorp):
src_rorp
.
getnumlinks
()
==
dest_rorp
.
getnumlinks
()
==
1
):
return
1
# Hard links don't apply
if
src_rorp
.
getnumlinks
()
<
dest_rorp
.
getnumlinks
():
return
0
"""The sha1 of linked files is only stored in the metadata of the first
linked file on the dest side. If the first linked file on the src side is
deleted, then the sha1 will also be deleted on the dest side, so we test for this
& report not equal so that another sha1 will be stored with the next linked
file on the dest side"""
if
(
not
islinked
(
src_rorp
)
and
not
dest_rorp
.
has_sha1
()):
return
0
if
src_rorp
.
getnumlinks
()
!=
dest_rorp
.
getnumlinks
():
return
0
src_key
=
get_inode_key
(
src_rorp
)
index
,
remaining
,
dest_key
,
digest
=
_inode_index
[
src_key
]
if
dest_key
==
"NA"
:
...
...
rdiff_backup/compare.py
View file @
1ef9675c
...
...
@@ -25,7 +25,7 @@ compare. This uses elements of the backup and restore modules.
"""
from
__future__
import
generators
import
Globals
,
restore
,
rorpiter
,
log
,
backup
,
static
,
rpath
,
hash
,
robust
import
Globals
,
restore
,
rorpiter
,
log
,
backup
,
static
,
rpath
,
hash
,
robust
,
Hardlink
def
Compare
(
src_rp
,
mirror_rp
,
inc_rp
,
compare_time
):
"""Compares metadata in src_rp dir with metadata in mirror_rp at time"""
...
...
@@ -80,14 +80,15 @@ def Verify(mirror_rp, inc_rp, verify_time):
bad_files
=
0
for
repo_rorp
in
repo_iter
:
if
not
repo_rorp
.
isreg
():
continue
if
not
repo_rorp
.
has_sha1
():
verify_sha1
=
get_hash
(
repo_rorp
)
if
not
verify_sha1
:
log
.
Log
(
"Warning: Cannot find SHA1 digest for file %s,
\
n
"
"perhaps because this feature was added in v1.1.1"
%
(
repo_rorp
.
get_indexpath
(),),
2
)
continue
fp
=
RepoSide
.
rf_cache
.
get_fp
(
base_index
+
repo_rorp
.
index
,
repo_rorp
)
computed_hash
=
hash
.
compute_sha1_fp
(
fp
)
if
computed_hash
==
repo_rorp
.
get_sha1
()
:
if
computed_hash
==
verify_sha1
:
log
.
Log
(
"Verified SHA1 digest of "
+
repo_rorp
.
get_indexpath
(),
5
)
else
:
bad_files
+=
1
...
...
@@ -95,11 +96,24 @@ def Verify(mirror_rp, inc_rp, verify_time):
"doesn't match recorded digest of
\
n
%s
\
n
"
"Your backup repository may be corrupted!"
%
(
repo_rorp
.
get_indexpath
(),
computed_hash
,
repo_rorp
.
get_sha1
()
),
2
)
verify_sha1
),
2
)
RepoSide
.
close_rf_cache
()
if
not
bad_files
:
log
.
Log
(
"Every file verified successfully."
,
3
)
return
bad_files
def
get_hash
(
repo_rorp
):
""" Try to get a sha1 digest from the repository. If hardlinks
are saved in the metadata, get the sha1 from the first hardlink """
Hardlink
.
add_rorp
(
repo_rorp
)
if
Hardlink
.
islinked
(
repo_rorp
):
verify_sha1
=
Hardlink
.
get_sha1
(
repo_rorp
)
elif
repo_rorp
.
has_sha1
():
verify_sha1
=
repo_rorp
.
get_sha1
()
else
:
verify_sha1
=
None
Hardlink
.
del_rorp
(
repo_rorp
)
return
verify_sha1
def
print_reports
(
report_iter
):
"""Given an iter of CompareReport objects, print them to screen"""
assert
not
Globals
.
server
...
...
@@ -199,12 +213,13 @@ class DataSide(backup.SourceStruct):
"""Like above, but also compare sha1 sums of any regular files"""
def
hashes_changed
(
src_rp
,
mir_rorp
):
"""Return 0 if their data hashes same, 1 otherwise"""
if
not
mir_rorp
.
has_sha1
():
verify_sha1
=
get_hash
(
mir_rorp
)
if
not
verify_sha1
:
log
.
Log
(
"Warning: Metadata file has no digest for %s, "
"unable to compare."
%
(
mir_rorp
.
get_indexpath
(),),
2
)
return
0
elif
(
src_rp
.
getsize
()
==
mir_rorp
.
getsize
()
and
hash
.
compute_sha1
(
src_rp
)
==
mir_rorp
.
get_sha1
()
):
hash
.
compute_sha1
(
src_rp
)
==
verify_sha1
):
return
0
return
1
...
...
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