1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-27 14:57:44 +00:00

have watchdog remove the lock file when finished loading the module

should be fixed fr fr this time ong
This commit is contained in:
Tahir 2023-02-04 21:47:41 +00:00
parent d2d451e670
commit 451f059bb7
3 changed files with 8 additions and 7 deletions

View file

@ -64,15 +64,15 @@ foreach(_scriptDir ${children})
COMMAND ${CMAKE_COMMAND} -E remove "${SCRIPT_LIB_DIR}/script_${_name}.exp"
COMMAND ${CMAKE_COMMAND} -E remove "${SCRIPT_LIB_DIR}/script_${_name}.lib"
COMMAND ${CMAKE_COMMAND} -E remove "${SCRIPT_LIB_DIR}/script_${_name}.ilk"
COMMAND ${CMAKE_COMMAND} -E copy "${SCRIPT_LIB_DIR}/script_${_name}.dll" ${SCRIPT_POSTBUILD_DIR}${ScriptTargetName}.dll_LOCK
COMMAND ${CMAKE_COMMAND} -E copy "${SCRIPT_LIB_DIR}/script_${_name}.dll" ${SCRIPT_POSTBUILD_DIR}${ScriptTargetName}_LOCK
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${SCRIPT_LIB_DIR}/script_${_name}.dll" ${SCRIPT_POSTBUILD_DIR}${ScriptTargetName}.dll
COMMAND ${CMAKE_COMMAND} -E remove ${SCRIPT_POSTBUILD_DIR}${ScriptTargetName}.dll_LOCK
COMMAND ${CMAKE_COMMAND} -E remove ${SCRIPT_POSTBUILD_DIR}${ScriptTargetName}_LOCK
)
else()
add_custom_command(TARGET "script_${_name}" POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${ScriptTargetName}> ${SCRIPT_POSTBUILD_DIR}$<TARGET_FILE_NAME:${ScriptTargetName}>_LOCK
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${ScriptTargetName}> ${SCRIPT_POSTBUILD_DIR}${ScriptTargetName}_LOCK
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:${ScriptTargetName}> ${SCRIPT_POSTBUILD_DIR}
COMMAND ${CMAKE_COMMAND} -E remove ${SCRIPT_POSTBUILD_DIR}$<TARGET_FILE_NAME:${ScriptTargetName}>_LOCK
COMMAND ${CMAKE_COMMAND} -E remove ${SCRIPT_POSTBUILD_DIR}${ScriptTargetName}_LOCK
)
endif()

View file

@ -81,6 +81,8 @@ namespace Sapphire::Scripting
void NativeScriptMgr::queueScriptReload( const std::string& name )
{
std::scoped_lock lock( m_mutex );
auto info = m_loader.getScriptInfo( name );
if( !info )
return;
@ -91,7 +93,6 @@ namespace Sapphire::Scripting
if( !unloadScript( info ) )
return;
std::scoped_lock lock( m_mutex );
m_scriptLoadQueue.push( libPath );
}

View file

@ -75,7 +75,8 @@ Sapphire::Scripting::ScriptInfo* Sapphire::Scripting::ScriptLoader::loadModule(
fs::path dest( cacheDir /= f.filename().string() );
// make sure the module has finished building before trying to copy it
if( fs::exists( f.string() + "_LOCK" ) )
const std::string readyFile( ( f.parent_path() / f.stem() ).string() + "_LOCK" );
if( fs::exists( readyFile ) )
return nullptr;
try
@ -112,7 +113,6 @@ Sapphire::Scripting::ScriptInfo* Sapphire::Scripting::ScriptLoader::loadModule(
info->library_path = f.string();
m_scriptMap.insert( std::make_pair( f.stem().string(), info ) );
return info;
}