Skip to content

Commit

Permalink
Fix bfs_client return value (#775)
Browse files Browse the repository at this point in the history
  • Loading branch information
lylei authored and Yang Ce committed Jan 9, 2017
1 parent bc1d30e commit 3410c07
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/client/bfs_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ int BfsTouchz(baidu::bfs::FS* fs, int argc, char* argv[]) {
ret = fs->OpenFile(argv[i], O_WRONLY, 0644, &file, baidu::bfs::WriteOptions());
if (ret != 0) {
fprintf(stderr, "Open %s fail\n", argv[i]);
return 1;
}
}
return 0;
Expand All @@ -68,7 +69,7 @@ int BfsRm(baidu::bfs::FS* fs, int argc, char* argv[]) {
for (int i = 0; i < argc; i++) {
ret = fs->DeleteFile(argv[i]);
if (!ret) {
printf("%s Removed\n", argv[i]);
printf("%s Removed\n", argv[i]);
} else {
fprintf(stderr, "Remove file fail %s\n", argv[i]);
ret = 1;
Expand Down Expand Up @@ -295,10 +296,12 @@ int BfsDu(baidu::bfs::FS* fs, int argc, char* argv[]) {
path = argv[i];
assert(path.size() > 0);
if (path[path.size() - 1] != '*') {
BfsDuV2(fs, path);
if (BfsDuV2(fs, path) == -1) {
return 1;
}
continue;
}

// Wildcard
path.resize(path.size() - 1);
ppath = path.substr(0, path.rfind('/') + 1);
Expand All @@ -309,13 +312,17 @@ int BfsDu(baidu::bfs::FS* fs, int argc, char* argv[]) {
ret = fs->ListDirectory(ppath.c_str(), &files, &num);
if (ret != 0) {
fprintf(stderr, "Path not found: %s\n", ppath.c_str());
continue;
return 1;
}
for (int j = 0; j < num; j++) {
std::string name(files[j].name);
if (name.find(prefix) != std::string::npos) {
int64_t sz = BfsDuV2(fs, ppath + name);
if (sz > 0) total_size += sz;
if (sz > 0) {
total_size += sz;
} else {
return 1;
}
}
}
printf("%s Total: %s\n", argv[i], baidu::common::HumanReadableString(total_size).c_str());
Expand Down

0 comments on commit 3410c07

Please sign in to comment.