{"record":{"id":"4aab6ba96e3382a7","repo":"lingochamp/FileDownloader","slug":"take-block-completed-snapshot-must-has-already-be","errorCode":null,"errorMessage":"take block completed snapshot, must has already be completed. %d %d","messagePattern":"take block completed snapshot, must has already be completed\\. (.+?) (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"library/src/main/java/com/liulishuo/filedownloader/message/MessageSnapshotTaker.java","lineNumber":93,"sourceCode":"            return new LargeMessageSnapshot.ErrorMessageSnapshot(id, sofar, error);\n        } else {\n            return new SmallMessageSnapshot.ErrorMessageSnapshot(id, (int) sofar, error);\n        }\n    }\n\n    public static MessageSnapshot catchPause(BaseDownloadTask task) {\n        if (task.isLargeFile()) {\n            return new LargeMessageSnapshot.PausedSnapshot(task.getId(),\n                    task.getLargeFileSoFarBytes(), task.getLargeFileTotalBytes());\n        } else {\n            return new SmallMessageSnapshot.PausedSnapshot(task.getId(),\n                    task.getSmallFileSoFarBytes(), task.getSmallFileTotalBytes());\n        }\n    }\n\n    public static MessageSnapshot takeBlockCompleted(MessageSnapshot snapshot) {\n        if (snapshot.getStatus() != FileDownloadStatus.completed) {\n            throw new IllegalStateException(\n                    FileDownloadUtils.formatString(\"take block completed snapshot, must has \"\n                                    + \"already be completed. %d %d\",\n                            snapshot.getId(), snapshot.getStatus()));\n        }\n\n        return new BlockCompleteMessage.BlockCompleteMessageImpl(snapshot);\n    }\n\n    public static MessageSnapshot take(byte status, FileDownloadModel model,\n                                       DownloadStatusCallback.ProcessParams processParams) {\n        final MessageSnapshot snapShot;\n        final int id = model.getId();\n        if (status == FileDownloadStatus.warn) {\n            throw new IllegalStateException(FileDownloadUtils.\n                    formatString(\"please use #catchWarn instead %d\", id));\n        }\n\n        switch (status) {","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/lingochamp/FileDownloader/blob/6237a8cac174bcc916e4342b14ab1ab72a5768d4/library/src/main/java/com/liulishuo/filedownloader/message/MessageSnapshotTaker.java#L75-L111","documentation":"Thrown by MessageSnapshotTaker.takeBlockCompleted when asked to wrap a snapshot whose status is not FileDownloadStatus.completed. Creating a block-complete message only makes sense on an already-completed task; the format args print the offending snapshot's id and its actual status code so you can identify which download reached this path in the wrong state.","triggerScenarios":"Thrown at library/src/main/java/com/liulishuo/filedownloader/message/MessageSnapshotTaker.java:93 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure takeBlockCompleted is only invoked from the completed-status callback (e.g. BaseDownloadTask#completed) after the task has fully finished","Check snapshot.getStatus() == FileDownloadStatus.completed before calling takeBlockCompleted","Verify the download flow is not re-dispatching an old snapshot after a status transition; use the latest snapshot from the MessageSnapshotGate"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6237a8cac174bcc916e4342b14ab1ab72a5768d4","analyzedAt":"2026-09-08T23:50:48.168Z","contentChangedAt":"2026-09-08T23:50:48.168Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}