File tree 5 files changed +38
-2
lines changed
src/main/java/com/google/devtools/build/lib 5 files changed +38
-2
lines changed Original file line number Diff line number Diff line change @@ -722,7 +722,8 @@ private static FileArtifactValue fileArtifactValueFromStat(
722
722
}
723
723
724
724
private void setPathPermissionsIfFile (Path path ) throws IOException {
725
- if (path .isFile (Symlinks .NOFOLLOW )) {
725
+ FileStatus stat = path .stat (Symlinks .NOFOLLOW );
726
+ if (stat .isFile () && stat .getPermissions () != outputPermissions .getPermissionsMode ()) {
726
727
setPathPermissions (path );
727
728
}
728
729
}
Original file line number Diff line number Diff line change @@ -120,7 +120,8 @@ public long getNodeId() {
120
120
return status .getInodeNumber ();
121
121
}
122
122
123
- int getPermissions () {
123
+ @ Override
124
+ public int getPermissions () {
124
125
return status .getPermissions ();
125
126
}
126
127
Original file line number Diff line number Diff line change @@ -85,4 +85,16 @@ public interface FileStatus {
85
85
* ought to cause the node ID of b to change, but appending / modifying b should not.
86
86
*/
87
87
long getNodeId () throws IOException ;
88
+
89
+ /**
90
+ * Returns the file's permissions in POSIX format (e.g. 0755) if possible without performing
91
+ * additional IO, otherwise (or if unsupported by the file system) returns -1.
92
+ *
93
+ * <p>If accurate group and other permissions aren't available, the returned value should attempt
94
+ * to mimic a umask of 022 (i.e. read and execute permissions extend to group and other, write
95
+ * does not).
96
+ */
97
+ default int getPermissions () {
98
+ return -1 ;
99
+ }
88
100
}
Original file line number Diff line number Diff line change @@ -120,6 +120,22 @@ public long getNodeId() {
120
120
return System .identityHashCode (this );
121
121
}
122
122
123
+ @ Override
124
+ public synchronized int getPermissions () {
125
+ int permissions = 0 ;
126
+ // Emulate the default umask of 022.
127
+ if (isReadable ) {
128
+ permissions |= 0444 ;
129
+ }
130
+ if (isWritable ) {
131
+ permissions |= 0200 ;
132
+ }
133
+ if (isExecutable ) {
134
+ permissions |= 0111 ;
135
+ }
136
+ return permissions ;
137
+ }
138
+
123
139
@ Override
124
140
public final InMemoryContentInfo inode () {
125
141
return this ;
Original file line number Diff line number Diff line change @@ -202,6 +202,12 @@ public long getNodeId() {
202
202
// TODO(bazel-team): Consider making use of attributes.fileKey().
203
203
return -1 ;
204
204
}
205
+
206
+ @ Override
207
+ public int getPermissions () {
208
+ // Files on Windows are implicitly readable and executable.
209
+ return 0555 | (attributes .isReadOnly () ? 0 : 0200 );
210
+ }
205
211
};
206
212
207
213
return status ;
You can’t perform that action at this time.
0 commit comments