Skip to content

Commit 090ebab

Browse files
committed
Revert "Add getLength() to FilePropertyVisitor.VisitState"
This reverts commit b5ebc13.
1 parent bceab24 commit 090ebab

4 files changed

Lines changed: 2 additions & 84 deletions

File tree

‎platforms/enterprise/enterprise-operations/src/main/java/org/gradle/api/internal/tasks/SnapshotTaskInputsBuildOperationType.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ interface InputFilePropertyVisitor {
129129
/**
130130
* Called when visiting a non-directory file.
131131
* <p>
132-
* {@link VisitState#getName()}, {@link VisitState#getPath()}, {@link VisitState#getHashBytes()} and {@link VisitState#getLength()} may be called during.
132+
* {@link VisitState#getName()}, {@link VisitState#getPath()} and {@link VisitState#getHashBytes()} may be called during.
133133
*/
134134
void file(VisitState state);
135135

‎platforms/enterprise/enterprise-operations/src/main/java/org/gradle/operations/execution/FilePropertyVisitor.java‎

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public interface FilePropertyVisitor {
5656
/**
5757
* Called when visiting a non-directory file.
5858
* <p>
59-
* {@link VisitState#getName()}, {@link VisitState#getPath()}, {@link VisitState#getHashBytes()} and {@link VisitState#getLength()} may be called during.
59+
* {@link VisitState#getName()}, {@link VisitState#getPath()} and {@link VisitState#getHashBytes()} may be called during.
6060
*/
6161
void file(VisitState state);
6262

@@ -122,14 +122,5 @@ interface VisitState {
122122
* Must not be called when the last visited location was a directory.
123123
*/
124124
byte[] getHashBytes();
125-
126-
/**
127-
* Returns the length in bytes of the last visited file.
128-
* <p>
129-
* Must not be called when the last visited location was a directory.
130-
*
131-
* @since 9.6
132-
*/
133-
long getLength();
134125
}
135126
}

‎subprojects/core/src/main/java/org/gradle/api/internal/tasks/BaseFilePropertyVisitState.java‎

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import org.gradle.internal.snapshot.DirectorySnapshot;
2525
import org.gradle.internal.snapshot.FileSystemLocationSnapshot;
2626
import org.gradle.internal.snapshot.FileSystemSnapshotHierarchyVisitor;
27-
import org.gradle.internal.snapshot.RegularFileSnapshot;
2827
import org.gradle.internal.snapshot.SnapshotVisitResult;
2928
import org.gradle.operations.execution.FilePropertyVisitor;
3029
import org.jspecify.annotations.NullMarked;
@@ -46,7 +45,6 @@ public abstract class BaseFilePropertyVisitState implements FilePropertyVisitor.
4645
String path;
4746
HashCode hash;
4847
int depth;
49-
long length;
5048

5149
protected BaseFilePropertyVisitState(Map<String, InputFilePropertySpec> propertySpecsByName) {
5250
this.propertySpecsByName = propertySpecsByName;
@@ -94,17 +92,11 @@ public byte[] getHashBytes() {
9492
return hash.toByteArray();
9593
}
9694

97-
@Override
98-
public long getLength() {
99-
return length;
100-
}
101-
10295
@Override
10396
public void enterDirectory(DirectorySnapshot physicalSnapshot) {
10497
this.path = physicalSnapshot.getAbsolutePath();
10598
this.name = physicalSnapshot.getName();
10699
this.hash = null;
107-
this.length = 0;
108100

109101
if (depth++ == 0) {
110102
preRoot();
@@ -137,9 +129,6 @@ public SnapshotVisitResult visitEntry(FileSystemLocationSnapshot snapshot) {
137129
this.path = snapshot.getAbsolutePath();
138130
this.name = snapshot.getName();
139131
this.hash = fingerprint.getNormalizedContentHash();
140-
this.length = snapshot instanceof RegularFileSnapshot
141-
? ((RegularFileSnapshot) snapshot).getMetadata().getLength()
142-
: 0;
143132

144133
boolean isRoot = depth == 0;
145134
if (isRoot) {
@@ -205,11 +194,6 @@ public byte[] getHashBytes() {
205194
throw new UnsupportedOperationException("Cannot query hash for directories");
206195
}
207196

208-
@Override
209-
public long getLength() {
210-
throw new UnsupportedOperationException("Cannot query length for directories");
211-
}
212-
213197
@Override
214198
public String getPropertyName() {
215199
return delegate.getPropertyName();

‎subprojects/core/src/testFixtures/groovy/org/gradle/api/internal/tasks/AbstractSnapshotInputsBuildOperationResultTest.groovy‎

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,11 @@ import org.gradle.internal.file.FileType
2626
import org.gradle.internal.fingerprint.CurrentFileCollectionFingerprint
2727
import org.gradle.internal.fingerprint.impl.DefaultFileSystemLocationFingerprint
2828
import org.gradle.internal.hash.TestHashCodes
29-
import org.gradle.internal.snapshot.RegularFileSnapshot
3029
import org.gradle.internal.snapshot.TestSnapshotFixture
3130
import org.gradle.test.precondition.Requires
3231
import org.gradle.test.preconditions.UnitTestPreconditions
3332
import spock.lang.Specification
3433

35-
import static org.gradle.internal.file.FileMetadata.AccessType.DIRECT
36-
import static org.gradle.internal.file.impl.DefaultFileMetadata.file
3734
import static org.gradle.internal.fingerprint.DirectorySensitivity.DEFAULT
3835
import static org.gradle.internal.fingerprint.DirectorySensitivity.IGNORE_DIRECTORIES
3936
import static org.gradle.internal.fingerprint.LineEndingSensitivity.NORMALIZE_LINE_ENDINGS
@@ -240,58 +237,4 @@ abstract class AbstractSnapshotInputsBuildOperationResultTest<RESULT extends Bas
240237
and:
241238
0 * visitor._
242239
}
243-
244-
@Requires(OsTestPreconditions.NotWindows)
245-
def "file visitor provides file length"() {
246-
given:
247-
def visitor = createMockVisitor()
248-
def inputFileProperty = Mock(InputFilePropertySpec) {
249-
getDirectorySensitivity() >> IGNORE_DIRECTORIES
250-
getLineEndingNormalization() >> NORMALIZE_LINE_ENDINGS
251-
getNormalizer() >> InputNormalizer.ABSOLUTE_PATH
252-
getPropertyName() >> 'foo'
253-
}
254-
def fileOneSnapshot = new RegularFileSnapshot(
255-
'/foo/one.txt', 'one.txt',
256-
TestHashCodes.hashCodeFrom(123),
257-
file(0, 1024, DIRECT)
258-
)
259-
def fileTwoSnapshot = new RegularFileSnapshot(
260-
'/foo/sub/two.txt', 'two.txt',
261-
TestHashCodes.hashCodeFrom(234),
262-
file(0, 2048, DIRECT)
263-
)
264-
def snapshots = directory('/foo', [
265-
fileOneSnapshot,
266-
directory('/foo/sub', [
267-
fileTwoSnapshot
268-
])
269-
])
270-
def beforeExecutionState = Mock(BeforeExecutionState) {
271-
getInputFileProperties() >> ImmutableSortedMap.of('foo',
272-
Mock(CurrentFileCollectionFingerprint) {
273-
getHash() >> TestHashCodes.hashCodeFrom(345)
274-
getFingerprints() >> [
275-
'/foo/one.txt': new DefaultFileSystemLocationFingerprint('/foo/one.txt', FileType.RegularFile, TestHashCodes.hashCodeFrom(123)),
276-
'/foo/sub/two.txt': new DefaultFileSystemLocationFingerprint('/foo/sub/two.txt', FileType.RegularFile, TestHashCodes.hashCodeFrom(234)),
277-
]
278-
getSnapshot() >> snapshots
279-
}
280-
)
281-
}
282-
def cachingState = CachingState.enabled(Mock(BuildCacheKey), beforeExecutionState)
283-
def buildOpResult = createSnapshotInputsBuildOperationResult(
284-
cachingState,
285-
[inputFileProperty] as Set
286-
)
287-
288-
when:
289-
buildOpResult.visitInputFileProperties(visitor)
290-
291-
then:
292-
1 * visitor.file { it.path == '/foo/one.txt' && it.length == 1024 }
293-
294-
and:
295-
1 * visitor.file { it.path == '/foo/sub/two.txt' && it.length == 2048 }
296-
}
297240
}

0 commit comments

Comments
 (0)