Check for directory locking not file

When creating a new file lock, we need to check if the containing
directory can be written, not if the file (which may not yet exist) can
be written

Fixes https://gitlab.com/kicad/code/kicad/-/issues/14942

(cherry picked from commit 6896148a10)
This commit is contained in:
Seth Hillbrand 2023-06-13 11:16:09 -07:00
parent 2e54232181
commit 32930319ea
1 changed files with 3 additions and 1 deletions

View File

@ -48,12 +48,14 @@ public:
if( filename.IsEmpty() ) if( filename.IsEmpty() )
return; return;
wxLogTrace( LCK, "Trying to lock %s", filename );
wxFileName fn( filename ); wxFileName fn( filename );
fn.SetName( "~" + fn.GetName() ); fn.SetName( "~" + fn.GetName() );
fn.SetExt( fn.GetExt() + ".lck" ); fn.SetExt( fn.GetExt() + ".lck" );
if( !fn.IsFileWritable() ) if( !fn.IsDirWritable() )
{ {
wxLogTrace( LCK, "File is not writable: %s", filename );
m_status = true; m_status = true;
m_removeOnRelease = false; m_removeOnRelease = false;
return; return;