Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
81330149
Commit
81330149
authored
May 05, 2010
by
Pieter Noordhuis
Browse files
ask for confirmation before AOF is truncated
parent
e51fa063
Changes
1
Hide whitespace changes
Inline
Side-by-side
redis-check-aof.c
View file @
81330149
...
...
@@ -154,16 +154,26 @@ int main(int argc, char **argv) {
}
long
pos
=
process
(
fp
);
if
(
pos
<
size
)
{
long
diff
=
size
-
pos
;
if
(
diff
>
0
)
{
if
(
fix
)
{
char
buf
[
2
];
printf
(
"This will shrink the AOF from %ld bytes, with %ld bytes, to %ld bytes
\n
"
,
size
,
diff
,
pos
);
printf
(
"Continue? [y/N]: "
);
if
(
fgets
(
buf
,
sizeof
(
buf
),
stdin
)
==
NULL
||
strncasecmp
(
buf
,
"y"
,
1
)
!=
0
)
{
printf
(
"Aborting...
\n
"
);
exit
(
1
);
}
if
(
ftruncate
(
fileno
(
fp
),
pos
)
==
-
1
)
{
printf
(
"
Could not
truncate AOF
to size %ld
\n
"
,
pos
);
printf
(
"
Failed to
truncate AOF
\n
"
);
exit
(
1
);
}
else
{
printf
(
"
AOF s
uccesfully truncated
to %ld bytes
\n
"
,
pos
);
printf
(
"
S
ucces
s
fully truncated
AOF
\n
"
);
}
}
else
{
printf
(
"First invalid operation at offset %ld
\n
"
,
pos
);
printf
(
"AOF is not valid
\n
"
);
exit
(
1
);
}
}
else
{
printf
(
"AOF is valid
\n
"
);
...
...
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