Skip to content

Commit

Permalink
Fix Crash in parse_directory, cleanup
Browse files Browse the repository at this point in the history
Bump version
  • Loading branch information
m4xw committed Mar 21, 2020
1 parent 8c01950 commit 8a382af
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ APP_TITLEID := 00FF00006D7470FF
# Meta
APP_TITLE := "mtp-server-nx"
APP_AUTHOR := "Gillou68310"
APP_VERSION := "1.1"
APP_VERSION := "1.2"

#---------------------------------------------------------------------------------
# options for code generation
Expand Down
17 changes: 11 additions & 6 deletions include/SwitchMtpDatabase.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,6 @@ class SwitchMtpDatabase : public android::MtpDatabase {
stat(p.string().c_str(), &result);
entry.last_modified = result.st_mtime;
db.insert( std::pair<MtpObjectHandle, DbEntry>(handle, entry) );
// if (local_server)
// local_server->sendObjectAdded(handle);

} else {
try {
Expand All @@ -130,10 +128,6 @@ class SwitchMtpDatabase : public android::MtpDatabase {
VLOG(1) << "Adding \"" << p.string() << "\"";

db.insert( std::pair<MtpObjectHandle, DbEntry>(handle, entry) );

// if (local_server)
// local_server->sendObjectAdded(handle);

} catch (const filesystem_error& ex) {
LOG(WARNING) << "There was an error reading file properties";
}
Expand All @@ -147,7 +141,18 @@ class SwitchMtpDatabase : public android::MtpDatabase {
{
DbEntry entry;
std::vector<path> v;

// XXX Hack: This shouldn't happen but whaterver
if(!is_directory(p))
{
add_file_entry(p, parent, storage);
if (db.find(parent) != db.end())
db.at(parent).scanned = true;
return;
}

directory_iterator i(p);

copy(i, directory_iterator(), std::back_inserter(v));

for (std::vector<path>::const_iterator it(v.begin()), it_end(v.end()); it != it_end; ++it)
Expand Down

0 comments on commit 8a382af

Please sign in to comment.