|
| 1 | +// Copyright 2024 The Bazel Authors. All rights reserved. |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | +package com.google.devtools.build.lib.versioning; |
| 15 | + |
| 16 | +import com.google.devtools.build.lib.vfs.Path; |
| 17 | +import java.io.IOException; |
| 18 | +import javax.annotation.Nullable; |
| 19 | + |
| 20 | +/** Strategy for retrieving the version number for paths. */ |
| 21 | +public interface LongVersionGetter { |
| 22 | + |
| 23 | + /** |
| 24 | + * Indicates the item was affected in currently evaluated versions. Outside of tests, it can only |
| 25 | + * be returned for changes in current client snapshot. |
| 26 | + */ |
| 27 | + // TODO(b/151473808): Do not request xattrs for paths without it outside of client snapshots in |
| 28 | + // tests. Rename the constant accordingly once we do so. |
| 29 | + long CURRENT_VERSION = Long.MAX_VALUE; |
| 30 | + |
| 31 | + /** |
| 32 | + * Returns version number when the provided file/symlink was last modified (or added). |
| 33 | + * |
| 34 | + * <p>Special value of {@link #CURRENT_VERSION} is used to indicate a file/symlink modified in |
| 35 | + * current client snapshot. |
| 36 | + */ |
| 37 | + long getFilePathOrSymlinkVersion(Path path) throws IOException; |
| 38 | + |
| 39 | + /** |
| 40 | + * Returns version number when the listing of given directory has last changed (or when the |
| 41 | + * directory was created if there were no changes since then). |
| 42 | + * |
| 43 | + * <p>Special value of {@link #CURRENT_VERSION} is used to indicate the listing has changed in |
| 44 | + * current client snapshot. |
| 45 | + */ |
| 46 | + long getDirectoryListingVersion(Path path) throws IOException; |
| 47 | + |
| 48 | + /** |
| 49 | + * Returns a version number for a currently nonexistent item. |
| 50 | + * |
| 51 | + * <p>This can be the version at which it was most recently deleted or one of the special cases |
| 52 | + * below. |
| 53 | + * |
| 54 | + * <ul> |
| 55 | + * <li><b>Deleted in Current Snapshot</b>: returns {@link #CURRENT_VERSION} |
| 56 | + * <li><b>External, unversioned, paths</b>: returns {@link #CURRENT_VERSION} |
| 57 | + * <li><b>Never existed in the first place</b>: returns null |
| 58 | + * <li><b>Parent directory doesn't exist</b>: returns null |
| 59 | + * </ul> |
| 60 | + */ |
| 61 | + @Nullable |
| 62 | + Long getNonexistentPathVersion(Path path) throws IOException; |
| 63 | +} |
0 commit comments