Skip to content

sync dir on windows Access is denied #75541

@ningmingxiao

Description

@ningmingxiao

when I try to fix containerd bug containerd/containerd#12301
I find it doesn't work on windows.

func syncDir(dir string) error {
	dirF, err := os.Open(dir)
	if err != nil {
		return fmt.Errorf("failed to open dir %s: %w", dir, err)
	}
	err = dirF.Sync()
	dirF.Close()
	if err != nil {
		return fmt.Errorf("failed to sync dir %s: %w", dir, err)
	}
	return nil
}

// doesn't work on windows.
if err := syncDir(filepath.Dir(target)); err != nil {
	return err
}

=== FAIL: plugins/content/local TestContent/UpdateStatus (0.03s)
testsuite.go:582: Commit failed: failed to sync dir C:\Users\RUNNER1\AppData\Local\Temp\content-suite-fs-1273908733\blobs\sha256: sync C:\Users\RUNNER1\AppData\Local\Temp\content-suite-fs-1273908733\blobs\sha256: Access is denied.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugReportIssues describing a possible bug in the Go implementation.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions