siyuan-note/siyuan · error

path, size or modification time differs

Error message

path, size or modification time differs

What it means

validateObsidianSourceMetadata stats the source file and compares its size and modification time against the values captured during import analysis. Any mismatch means the file on disk is not the one that was analyzed, so validation fails with 'path, size or modification time differs'.

Solutions

  1. Re-run the import analysis so recorded Size/ModTime match the current file
  2. Restore the file to its analyzed state (revert edits, re-download from sync)
  3. If only mtime changed but content is identical, re-copy the file or update the captured metadata before validating

Example fix

// before: stale recorded metadata
if info.Size() != file.Size || !info.ModTime().Equal(file.ModTime) {
    return errors.New("path, size or modification time differs")
}
// after: refresh recorded metadata when content is unchanged (same content hash)
if info.Size() != file.Size || !info.ModTime().Equal(file.ModTime) {
    if sameHash(file.AbsPath, file.ContentHash) {
        file.Size, file.ModTime = info.Size(), info.ModTime()
    } else {
        return errors.New("path, size or modification time differs")
    }
}
Defensive patterns

Strategy: validation

Validate before calling

info, err := os.Stat(file.AbsPath)
if err != nil {
    return err
}
if info.Size() != file.Size || !info.ModTime().Equal(file.ModTime) {
    return errors.New("file changed since analysis; re-run import")
}

Prevention

When it happens

Trigger: Calling `validateObsidianSourceMetadata(file)` where `os.Stat(file.AbsPath)` succeeds but `info.Size() != file.Size` or `!info.ModTime().Equal(file.ModTime)`.

Common situations: The Obsidian attachment was re-saved (touch/mtime change with same content), synced/rewritten by cloud storage, or replaced by a different file with the same name between analysis and import.

Understand the failure class

Background: Checksum mismatch errors: "checksum verification failed", "digest mismatch", "expected vs actual checksum" — what they mean and how to fix them — this error's family across 41 libraries.

Related errors


AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19). Data as JSON: /api/errors/8ac0d980571ab3bc. Report an issue: GitHub.

Appendix: source

Thrown at kernel/model/import_obsidian.go:1888

	for _, asset := range vault.ImportAssets {
		if err := ctx.Err(); err != nil {
			return err
		}
		if err := validateObsidianSourceMetadata(asset.Source); err != nil {
			return newObsidianUserError(346, asset.Source.RelPath,
				fmt.Errorf("attachment [%s] changed after analysis: %w", asset.Source.RelPath, err))
		}
	}
	return nil
}

func validateObsidianSourceMetadata(file *obsidianSourceFile) error {
	info, err := os.Stat(file.AbsPath)
	if err != nil {
		return err
	}
	if info.Size() != file.Size || !info.ModTime().Equal(file.ModTime) {
		return errors.New("path, size or modification time differs")
	}
	return nil
}

func transformObsidianMarkdown(vault *obsidianVaultContext, doc *obsidianDocPlan, data []byte) ([]byte, *obsidianTransformStats) {
	scan := scanObsidianSource(data)
	stats := &obsidianTransformStats{ReservedIDs: map[string]bool{}, FootnoteIDs: map[string]bool{}, PreservedComments: len(scan.Comments)}
	for _, heading := range doc.Headings {
		stats.ReservedIDs[heading.ID] = true
	}
	for _, id := range doc.BlockIDs {
		stats.ReservedIDs[id] = true
	}

	type replacement struct {
		start int
		end   int
		text  string

View on GitHub (pinned to 9f775e8a12)