X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/e491542da563673b49c6f6df9948ffaffbeed4fb..f5804888e40c2d4b679bdb38e7cba92b527271d4:/sbr/seq_save.c?ds=inline diff --git a/sbr/seq_save.c b/sbr/seq_save.c index 83753afb..5148f745 100644 --- a/sbr/seq_save.c +++ b/sbr/seq_save.c @@ -77,6 +77,8 @@ priv: context_del (attr); /* delete sequence from context */ if (!fp) { + int failed_to_lock = 0; + /* * Attempt to open file for public sequences. * If that fails (probably because folder is @@ -90,10 +92,16 @@ priv: mp->seqname = NULL; rewind(fp); ftruncate(fileno(fp), 0); - } else if ((fp = lkfopendata (seqfile, "w")) == NULL - && (unlink (seqfile) == -1 || - (fp = lkfopendata (seqfile, "w")) == NULL)) { - admonish (attr, "unable to write"); + } else if ((fp = lkfopendata (seqfile, "w", &failed_to_lock)) + == NULL + && (m_unlink (seqfile) == -1 || + (fp = lkfopendata (seqfile, "w", &failed_to_lock)) + == NULL)) { + if (failed_to_lock) { + admonish (attr, "unable to lock"); + } else { + admonish (attr, "unable to write"); + } goto priv; } @@ -118,7 +126,7 @@ priv: * public sequences, then remove that file. */ if (!is_readonly(mp)) - unlink (seqfile); + (void) m_unlink (seqfile); } /*