Skip to content

Commit

Permalink
Use update() to directly change the filename in gridfs_rename().
Browse files Browse the repository at this point in the history
  • Loading branch information
Imroy committed Nov 27, 2013
1 parent 6eb7857 commit 9969c99
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions ops_metadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,21 +188,9 @@ int gridfs_rename(const char* old_path, const char* new_path) {
if (file_obj.isEmpty())
return -ENOENT;

mongo::BSONObjBuilder b;
std::set<std::string> field_names;
file_obj.getFieldNames(field_names);

for (auto name : field_names) {
if (name != "filename") {
b.append(file_obj.getField(name));
}
}

b << "filename" << new_path;

client.update(db_name() + ".files",
BSON("_id" << file_obj.getField("_id")),
b.obj());
BSON("$set" << BSON("filename" << new_path)));

return 0;
}
Expand Down

0 comments on commit 9969c99

Please sign in to comment.