<p></p>
<p><b>@codebrainz</b> commented on this pull request.</p>

<hr>

<p>In <a href="https://github.com/geany/geany/pull/2586#discussion_r488350551">src/project.c</a>:</p>
<pre style='color:#555'>> @@ -772,6 +772,36 @@ static gboolean update_config(const PropertyDialogElements *e, gboolean new_proj
                }
                g_free(locale_path);
        }
+
+       /* create filename path if it doesn't exist and if file name ends with '.geany' */
+       if ((err_code = utils_is_file_writable(locale_filename)) != 0 &&
</pre>
<p>Since the new code doesn't use the value assigned to <code>err_code</code> here, doesn't seem much point in assigning to it.</p>
<p>Moreover, this use of <code>utils_is_file_writable()</code> seems like it's deceptively subtle, given what that function does and the comment above it. It might also result in a weird race condition.</p>
<p>Since you're using <code>utils_mkdir(..., TRUE)</code> below, which will succeed if the directory already exists, I think you could probably just drop this whole <code>if</code> block. Just get the dirname of the project file and try and create it with <code>utils_mkdir(..., TRUE)</code> as you already do.</p>
<p>Given the above, the logic could probably be restructured like this (untested/example code):</p>
<div class="highlight highlight-source-c"><pre>gchar *project_file_dirname = g_path_get_dirname(locale_filename);
gboolean create_dir = <span class="pl-c1">FALSE</span>;

<span class="pl-c"><span class="pl-c">//</span> if the project file's directory doesn't exist, offer the user to create it</span>
<span class="pl-k">if</span> (! g_file_test(project_file_dirname, G_FILE_TEST_EXISTS))
    create_dir = dialogs_show_question_full(...);

<span class="pl-c"><span class="pl-c">//</span> if the project file's directory doesn't exist and the user wants to try and create it</span>
<span class="pl-k">if</span> (create_dir)
{
    <span class="pl-c"><span class="pl-c">//</span> try and create the project file's directory recursively, if it doesn't already exist</span>
    err_code = <span class="pl-c1">utils_mkdir</span>(project_file_dirname, <span class="pl-c1">TRUE</span>);
    <span class="pl-k">if</span> (err_code != <span class="pl-c1">0</span>)
    {
        <span class="pl-c1">SHOW_ERR1</span>(...);
        <span class="pl-c1">g_free</span>(project_file_dirname);
        <span class="pl-k">return</span> <span class="pl-c1">FALSE</span>;
    }
}
<span class="pl-k">else</span>
{
    <span class="pl-c"><span class="pl-c">//</span> TODO: should this be handled?</span>
}

<span class="pl-en">g_free</span>(project_file_dirname);</pre></div>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/geany/geany/pull/2586#pullrequestreview-488285588">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAIOWJ77ERVUEQJ5QXUT3NDSF3I4NANCNFSM4RLUS2GA">unsubscribe</a>.<img src="https://github.com/notifications/beacon/AAIOWJ224YI2X4UJ2FCVU5DSF3I4NA5CNFSM4RLUS2GKYY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGODUNKLFA.gif" height="1" width="1" alt="" /></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/geany/geany/pull/2586#pullrequestreview-488285588",
"url": "https://github.com/geany/geany/pull/2586#pullrequestreview-488285588",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>