You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by nw...@apache.org on 2013/08/26 00:57:12 UTC
[lucy-commits] [10/14] git commit: refs/heads/cfish-string-prep1 - Eliminate CB_Chop
in BackgroundMerger and Indexer
Eliminate CB_Chop in BackgroundMerger and Indexer
Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/3897a0b6
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/3897a0b6
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/3897a0b6
Branch: refs/heads/cfish-string-prep1
Commit: 3897a0b6928b2f3c29d017648026e327e68e53ec
Parents: faf4060
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Sun Aug 25 23:57:18 2013 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Mon Aug 26 00:54:48 2013 +0200
----------------------------------------------------------------------
core/Lucy/Index/BackgroundMerger.c | 10 ++++++++--
core/Lucy/Index/Indexer.c | 10 ++++++++--
2 files changed, 16 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy/blob/3897a0b6/core/Lucy/Index/BackgroundMerger.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/BackgroundMerger.c b/core/Lucy/Index/BackgroundMerger.c
index 53a88ba..31eba25 100644
--- a/core/Lucy/Index/BackgroundMerger.c
+++ b/core/Lucy/Index/BackgroundMerger.c
@@ -483,10 +483,16 @@ BGMerger_Commit_IMP(BackgroundMerger *self) {
if (ivars->needs_commit) {
bool success = false;
- CharBuf *temp_snapfile = CB_Clone(ivars->snapfile);
+ CharBuf *temp_snapfile = ivars->snapfile;
// Rename temp snapshot file.
- CB_Chop(ivars->snapfile, sizeof(".temp") - 1);
+ size_t ext_len = sizeof(".temp") - 1;
+ size_t snapfile_len = CB_Length(temp_snapfile);
+ if (snapfile_len <= ext_len) {
+ THROW(ERR, "Invalid snapfile name: %o", temp_snapfile);
+ }
+ ivars->snapfile = CB_SubString(temp_snapfile, 0,
+ snapfile_len - ext_len);
success = Folder_Hard_Link(ivars->folder, temp_snapfile,
ivars->snapfile);
Snapshot_Set_Path(ivars->snapshot, ivars->snapfile);
http://git-wip-us.apache.org/repos/asf/lucy/blob/3897a0b6/core/Lucy/Index/Indexer.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/Indexer.c b/core/Lucy/Index/Indexer.c
index c1423b1..923f51a 100644
--- a/core/Lucy/Index/Indexer.c
+++ b/core/Lucy/Index/Indexer.c
@@ -554,8 +554,14 @@ Indexer_Commit_IMP(Indexer *self) {
bool success;
// Rename temp snapshot file.
- CharBuf *temp_snapfile = CB_Clone(ivars->snapfile);
- CB_Chop(ivars->snapfile, sizeof(".temp") - 1);
+ CharBuf *temp_snapfile = ivars->snapfile;
+ size_t ext_len = sizeof(".temp") - 1;
+ size_t snapfile_len = CB_Length(temp_snapfile);
+ if (snapfile_len <= ext_len) {
+ THROW(ERR, "Invalid snapfile name: %o", temp_snapfile);
+ }
+ ivars->snapfile = CB_SubString(temp_snapfile, 0,
+ snapfile_len - ext_len);
Snapshot_Set_Path(ivars->snapshot, ivars->snapfile);
success = Folder_Rename(ivars->folder, temp_snapfile, ivars->snapfile);
DECREF(temp_snapfile);