From 3f67108249b5c4f97841beee18fdd761919fe754 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Tue, 11 Dec 2018 10:26:26 -0800 Subject: Fixed MyriadFS path exists error. Also started some FS related thread safety. --- src/unstable/myriadfs.cpp | 7 ++++--- src/unstable/myriadfs.h | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/unstable/myriadfs.cpp b/src/unstable/myriadfs.cpp index cbc9e27..673956e 100644 --- a/src/unstable/myriadfs.cpp +++ b/src/unstable/myriadfs.cpp @@ -165,8 +165,6 @@ void Bu::MyriadFs::create( const Bu::String &sPath, uint16_t iPerms, { iNode = lookupInode( sPath, iParent ); sio << "File found." << sio.nl; - // The file was found - throw Bu::MyriadFsException("Path already exists."); } catch( Bu::MyriadFsException &e ) { @@ -185,6 +183,8 @@ void Bu::MyriadFs::create( const Bu::String &sPath, uint16_t iPerms, iNode = create( iParent, sName, iPerms, uSpecial ); sio << "New iNode: " << iNode << sio.nl; } + // The file was found + //throw Bu::MyriadFsException("Path already exists."); } void Bu::MyriadFs::mkDir( const Bu::String &sPath, uint16_t iPerms ) @@ -200,7 +200,6 @@ void Bu::MyriadFs::mkSymLink( const Bu::String &sTarget, try { iNode = lookupInode( sPath, iParent ); - throw Bu::MyriadFsException("Path already exists."); } catch( Bu::MyriadFsException &e ) { @@ -220,7 +219,9 @@ void Bu::MyriadFs::mkSymLink( const Bu::String &sTarget, sio << "New iNode: " << iNode << sio.nl; MyriadStream ms = openByInode( iNode ); ms.write( sTarget ); + return; } + throw Bu::MyriadFsException("Path already exists."); } void Bu::MyriadFs::mkHardLink( const Bu::String &sTarget, diff --git a/src/unstable/myriadfs.h b/src/unstable/myriadfs.h index f9faf9a..5a79c39 100644 --- a/src/unstable/myriadfs.h +++ b/src/unstable/myriadfs.h @@ -11,6 +11,7 @@ #include #include "bu/myriad.h" +#include "bu/readwritemutex.h" namespace Bu { @@ -194,6 +195,7 @@ namespace Bu private: Bu::Stream &rStore; Bu::Myriad mStore; + Bu::ReadWriteMutex mNodeIndex; NodeIndex hNodeIndex; int32_t iUser; int32_t iGroup; -- cgit v1.2.3