Skip to content

fix: Add path prefix presence flag and tests for AppFileInfo#386

Open
anxinxu wants to merge 2 commits intoLongi94:masterfrom
anxinxu:master
Open

fix: Add path prefix presence flag and tests for AppFileInfo#386
anxinxu wants to merge 2 commits intoLongi94:masterfrom
anxinxu:master

Conversation

@anxinxu
Copy link
Copy Markdown
Contributor

@anxinxu anxinxu commented Apr 29, 2026

Description

This PR improves AppFileInfo handling for path_prefix_index presence semantics while preserving backward compatibility.

  • Added hasPathPrefixIndex to AppFileInfo so callers can explicitly distinguish whether path_prefix_index is present in the protobuf payload.
  • Kept pathPrefixIndex as Int to avoid breaking existing callers that rely on the previous API shape.
  • Added focused unit tests to cover both key cases:
    • path_prefix_index is absent -> hasPathPrefixIndex == false
    • path_prefix_index is present and equals 0 -> hasPathPrefixIndex == true and pathPrefixIndex == 0

Checklist

  • Code compiles correctly
  • All tests passing
  • Samples run successfully
  • Extended the README / documentation, if necessary

@anxinxu
Copy link
Copy Markdown
Contributor Author

anxinxu commented Apr 29, 2026

@LossyDragon Could you please review this PR? It adds a backward-compatible presence flag for pathPrefixIndex in AppFileInfo and includes tests for both missing and zero-index cases. Thanks!

Copy link
Copy Markdown
Collaborator

@LossyDragon LossyDragon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mind changing the test class to Java? I try to keep the tests in Java (for now) to ensure Java/Kotlin compatibility.

package in.dragonbra.javasteam.steam.handlers.steamcloud;

import in.dragonbra.javasteam.protobufs.steamclient.SteammessagesCloudSteamclient;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public class AppFileInfoTest {

    @Test
    public void hasPathPrefixIndexIsFalseWhenFieldIsMissing() {
        var response = SteammessagesCloudSteamclient.CCloud_AppFileInfo.newBuilder()
                .setFileName("save.dat")
                .build();

        var info = new AppFileInfo(response);

        Assertions.assertFalse(info.getHasPathPrefixIndex());
    }

    @Test
    public void hasPathPrefixIndexIsTrueWhenIndexIsZero() {
        var response = SteammessagesCloudSteamclient.CCloud_AppFileInfo.newBuilder()
                .setFileName("save.dat")
                .setPathPrefixIndex(0)
                .build();

        var info = new AppFileInfo(response);

        Assertions.assertTrue(info.getHasPathPrefixIndex());
        Assertions.assertEquals(0, info.getPathPrefixIndex());
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants