Repository navigation
Conversation
Set state.error = FileViewError::Unknown when QSaveFile::commit() or QFile::flush() fails in FileViewWriter::write, and mark state.exists = true once a write succeeds so creating a new file updates loaded. In FileView::updateState, do not overwrite state.data, set mPrepared, or emit dataChanged/textChanged when a write fails unless an old path's non-empty data is being cleared. Only compare against state.data in writeCmpData() when mPrepared is true and state.error is Success. Clear liveOperation before updateState() and completion signals in operationFinished() and waitForJob(), and only call tryCancel() on liveReader() in cancelAsync() so waiting on an in-flight writer does not abort it and report Success.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe your changes
Fixes several bugs around
FileViewwrite failures and retries:FileViewWriter::writewarns whenQSaveFile::commit()fails (Write of ... failed: Atomic commit failed.) but does not setstate.error = FileViewError::Unknown, sosaved()is emitted instead ofsaveFailed(). SinceQFileDevice::write()buffers up to 16 KiB in user space, small writes to a full disk only fail incommit()(orflush()whenatomicWritesis false).FileViewReader,FileViewWriterpopulatesstate.databefore running. On a failed write,updateState()copies that unwrittenstate.dataintothis->state.dataand emitsdataChanged()/textChanged(). BecausesetText()andsetData()skip writes matchingwriteCmpData(), retryingsetText()/setData()/writeAdapter()with the same content aftersaveFailed()is a no-op.FileViewWriter::writesetsstate.exists = info.exists()before creating the file and never updates it on success, leavingloadedfalse after writing a new file.cancelAsync()callstryCancel()before checkingliveReader()vsliveWriter(); an in-flight writer waited on bywaitForJob()skipswrite()withstate.error == Successand emitssaved().operationFinished()andwaitForJob()also clearliveOperationafter emitting, so a retry started fromonSaveFailedre-enterswaitForJob()on the finished writer and then has its newliveOperationoverwritten withnullptr.Details and descisions
state.error = FileViewError::Unknownand return whencommit()(orfile->flush()for non-atomic writes) fails, and setstate.exists = trueat the end of a successful write.isWritetoupdateState(). On a failed write, keepthis->state.dataandthis->mPreparedunchanged (or clearthis->state.dataifpathChangedand it was non-empty), and only return&this->state.datafromwriteCmpData()whenthis->mPrepared && this->state.error == FileViewError::Success.tryCancel()forliveReader()incancelAsync(), and clearthis->liveOperationbeforeupdateState()and signal emission inoperationFinished()andwaitForJob().src/io/test/fileview.cppcoveringQSaveFile::commit()failure (RLIMIT_FSIZE = 0), back-to-back writes on a read-only directory, and retryingsetText()fromonSaveFailed; fails before, passes after.Open concerns
None.
Participation
Found while testing full-disk and read-only state handling in my shell.