| 1 | package lfsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/ |
| 2 | |
| 3 | import ( |
| 4 | "bytesscip-go gomod github.com/golang/go/src go1.25.0 bytes/" |
| 5 | "crypto/sha256scip-go gomod github.com/golang/go/src go1.25.0 `crypto/sha256`/" |
| 6 | "encoding/hexscip-go gomod github.com/golang/go/src go1.25.0 `encoding/hex`/" |
| 7 | "ioscip-go gomod github.com/golang/go/src go1.25.0 io/" |
| 8 | "osscip-go gomod github.com/golang/go/src go1.25.0 os/" |
| 9 | |
| 10 | "github.com/git-lfs/git-lfs/v3/errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/" |
| 11 | "github.com/git-lfs/git-lfs/v3/toolsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/" |
| 12 | ) |
| 13 | |
| 14 | type cleanedAssetscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/cleanedAsset# struct { |
| 15 | Filenamescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/cleanedAsset#Filename. string |
| 16 | *Pointerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/cleanedAsset#Pointer. |
| 17 | } |
| 18 | |
| 19 | func (f *GitFilterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/GitFilter#) Cleanscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/GitFilter#Clean().(reader ioscip-go gomod github.com/golang/go/src go1.25.0 io/.Readerscip-go gomod github.com/golang/go/src go1.25.0 io/Reader#, fileName string, fileSize int64, cb toolsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/.CopyCallbackscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/CopyCallback#) (*cleanedAssetscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/cleanedAsset#, error) { |
| 20 | extensions, err := f.cfgscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/GitFilter#cfg..SortedExtensionsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Configuration#SortedExtensions().() |
| 21 | if err != nil { |
| 22 | return nil, err |
| 23 | } |
| 24 | |
| 25 | var oid string |
| 26 | var size int64 |
| 27 | var tmp *osscip-go gomod github.com/golang/go/src go1.25.0 os/.Filescip-go gomod github.com/golang/go/src go1.25.0 os/File# |
| 28 | var exts []*PointerExtensionscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PointerExtension# |
| 29 | if len(extensions) > 0 { |
| 30 | request := &pipeRequestscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/pipeRequest#{"clean", reader, fileName, extensions} |
| 31 | |
| 32 | var response pipeResponsescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/pipeResponse# |
| 33 | if response, err = pipeExtensionsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/pipeExtensions().(f.cfgscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/GitFilter#cfg., request); err != nil { |
| 34 | return nil, err |
| 35 | } |
| 36 | |
| 37 | oid = response.resultsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/pipeResponse#results.[len(response.resultsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/pipeResponse#results.)-1].oidOutscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/pipeExtResult#oidOut. |
| 38 | tmp = response.filescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/pipeResponse#file. |
| 39 | var stat osscip-go gomod github.com/golang/go/src go1.25.0 os/.FileInfoscip-go gomod github.com/golang/go/src go1.25.0 os/FileInfo# |
| 40 | if stat, err = osscip-go gomod github.com/golang/go/src go1.25.0 os/.Statscip-go gomod github.com/golang/go/src go1.25.0 os/Stat().(tmp.Namescip-go gomod github.com/golang/go/src go1.25.0 os/File#Name().()); err != nil { |
| 41 | return nil, err |
| 42 | } |
| 43 | size = stat.Sizescip-go gomod github.com/golang/go/src go1.25.0 `io/fs`/FileInfo#Size().() |
| 44 | |
| 45 | for _, result := range response.resultsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/pipeResponse#results. { |
| 46 | if result.oidInscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/pipeExtResult#oidIn. != result.oidOutscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/pipeExtResult#oidOut. { |
| 47 | ext := NewPointerExtensionscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/NewPointerExtension().(result.namescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/pipeExtResult#name., len(exts), result.oidInscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/pipeExtResult#oidIn.) |
| 48 | exts = append(exts, ext) |
| 49 | } |
| 50 | } |
| 51 | } else { |
| 52 | oid, size, tmp, err = f.copyToTempscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/GitFilter#copyToTemp().(reader, fileSize, cb) |
| 53 | if err != nil { |
| 54 | return nil, err |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | pointer := NewPointerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/NewPointer().(oid, size, exts) |
| 59 | return &cleanedAssetscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/cleanedAsset#{tmp.Namescip-go gomod github.com/golang/go/src go1.25.0 os/File#Name().(), pointer}, err |
| 60 | } |
| 61 | |
| 62 | func (f *GitFilterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/GitFilter#) copyToTempscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/GitFilter#copyToTemp().(reader ioscip-go gomod github.com/golang/go/src go1.25.0 io/.Readerscip-go gomod github.com/golang/go/src go1.25.0 io/Reader#, fileSize int64, cb toolsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/.CopyCallbackscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/CopyCallback#) (oid string, size int64, tmp *osscip-go gomod github.com/golang/go/src go1.25.0 os/.Filescip-go gomod github.com/golang/go/src go1.25.0 os/File#, err error) { |
| 63 | tmp, err = TempFilescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/TempFile().(f.cfgscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/GitFilter#cfg., "") |
| 64 | if err != nil { |
| 65 | return |
| 66 | } |
| 67 | |
| 68 | defer tmp.Closescip-go gomod github.com/golang/go/src go1.25.0 os/File#Close().() |
| 69 | |
| 70 | oidHash := sha256scip-go gomod github.com/golang/go/src go1.25.0 `crypto/sha256`/.Newscip-go gomod github.com/golang/go/src go1.25.0 `crypto/sha256`/New().() |
| 71 | writer := ioscip-go gomod github.com/golang/go/src go1.25.0 io/.MultiWriterscip-go gomod github.com/golang/go/src go1.25.0 io/MultiWriter().(oidHash, tmp) |
| 72 | |
| 73 | ptr, buf, err := DecodeFromscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/DecodeFrom().(reader) |
| 74 | |
| 75 | by := make([]byte, BlobSizeCutoffscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/BlobSizeCutoff.) |
| 76 | n, rerr := buf.Readscip-go gomod github.com/golang/go/src go1.25.0 io/Reader#Read().(by) |
| 77 | by = by[:n] |
| 78 | |
| 79 | if rerr != nil || (err == nil && len(by) < BlobSizeCutoffscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/BlobSizeCutoff.) { |
| 80 | err = errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/.NewCleanPointerErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/NewCleanPointerError().(ptr, by) |
| 81 | return |
| 82 | } |
| 83 | |
| 84 | var from ioscip-go gomod github.com/golang/go/src go1.25.0 io/.Readerscip-go gomod github.com/golang/go/src go1.25.0 io/Reader# = bytesscip-go gomod github.com/golang/go/src go1.25.0 bytes/.NewReaderscip-go gomod github.com/golang/go/src go1.25.0 bytes/NewReader().(by) |
| 85 | if fileSize < 0 || int64(len(by)) < fileSize { |
| 86 | // If there is still more data to be read from the file, tack on |
| 87 | // the original reader and continue the read from there. |
| 88 | from = ioscip-go gomod github.com/golang/go/src go1.25.0 io/.MultiReaderscip-go gomod github.com/golang/go/src go1.25.0 io/MultiReader().(from, reader) |
| 89 | } |
| 90 | |
| 91 | size, err = toolsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/.CopyWithCallbackscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/CopyWithCallback().(writer, from, fileSize, cb) |
| 92 | |
| 93 | if err != nil { |
| 94 | return |
| 95 | } |
| 96 | |
| 97 | oid = hexscip-go gomod github.com/golang/go/src go1.25.0 `encoding/hex`/.EncodeToStringscip-go gomod github.com/golang/go/src go1.25.0 `encoding/hex`/EncodeToString().(oidHash.Sumscip-go gomod github.com/golang/go/src go1.25.0 hash/Hash#Sum().(nil)) |
| 98 | return |
| 99 | } |
| 100 | |
| 101 | func (a *cleanedAssetscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/cleanedAsset#) Teardownscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/cleanedAsset#Teardown().() error { |
| 102 | return osscip-go gomod github.com/golang/go/src go1.25.0 os/.Removescip-go gomod github.com/golang/go/src go1.25.0 os/Remove().(a.Filenamescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/cleanedAsset#Filename.) |
| 103 | } |