Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Adding --skip-problem-assets global param #804

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

coulterpeterson
Copy link

When performing large Google Photos uploads, I kept getting a halting "413 Request Entity Too Large" error, and excluding each file as it came up became too cumbersome, so this lets the user optionally skip those files, so they can go back and manually deal with them by referencing the log.

@simulot
Copy link
Owner

simulot commented Mar 10, 2025

Thank you for the PR.

A few remarks:

Since v0.24.2 there is the possibility to keep immich-go running after an error --on-server-errors.
Why not using it?

  • The error message can improved as you propose.
  • The DeleteServer asset is a code remaining from the time where ReplaceAsset API wasn't implemented. I need to prune this code!
  • The error message enhancement can be done directly here 👇🏼 . You'd have to duplicate the code

    immich-go/immich/upload.go

    Lines 33 to 108 in c80672b

    func (ic *ImmichClient) uploadAsset(ctx context.Context, la *assets.Asset, endPoint string, replaceID string) (AssetResponse, error) {
    if ic.dryRun {
    return AssetResponse{
    ID: uuid.NewString(),
    Status: UploadCreated,
    }, nil
    }
    var ar AssetResponse
    ext := path.Ext(la.OriginalFileName)
    if strings.TrimSuffix(la.OriginalFileName, ext) == "" {
    la.OriginalFileName = "No Name" + ext // fix #88, #128
    }
    if strings.ToUpper(ext) == ".MP" {
    ext = ".MP4" // #405
    la.OriginalFileName = la.OriginalFileName + ".MP4"
    }
    mtype := ic.TypeFromExt(ext)
    switch mtype {
    case "video", "image":
    default:
    return ar, fmt.Errorf("type file not supported: %s", path.Ext(la.OriginalFileName))
    }
    f, err := la.OpenFile()
    if err != nil {
    return ar, err
    }
    defer f.Close()
    s, err := f.Stat()
    if err != nil {
    return ar, err
    }
    callValues := ic.prepareCallValues(la, s, ext, mtype)
    body, pw := io.Pipe()
    m := multipart.NewWriter(pw)
    go func() {
    defer func() {
    m.Close()
    pw.Close()
    }()
    err = ic.writeMultipartFields(m, callValues)
    if err != nil {
    return
    }
    err = ic.writeFilePart(m, f, la.OriginalFileName, mtype)
    if err != nil {
    return
    }
    if la.FromSideCar != nil && strings.HasSuffix(strings.ToLower(la.FromSideCar.File.Name()), ".xmp") {
    err = ic.writeSideCarPart(m, la)
    if err != nil {
    return
    }
    }
    }()
    var errCall error
    switch endPoint {
    case EndPointAssetUpload:
    errCall = ic.newServerCall(ctx, EndPointAssetUpload).
    do(postRequest("/assets", m.FormDataContentType(), setContextValue(callValues), setAcceptJSON(), setBody(body)), responseJSON(&ar))
    case EndPointAssetReplace:
    errCall = ic.newServerCall(ctx, EndPointAssetReplace).
    do(putRequest("/assets/"+replaceID+"/original", setContextValue(callValues), setAcceptJSON(), setContentType(m.FormDataContentType()), setBody(body)), responseJSON(&ar))
    }
    err = errors.Join(err, errCall)
    return ar, err
    }

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants