Skip to content

Commit 84ea6ce

Browse files
committed
update folder path permission
1 parent 3509d13 commit 84ea6ce

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

services/secondary-storage/server/src/main/java/org/apache/cloudstack/storage/template/UploadManagerImpl.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import java.io.File;
2020
import java.net.URI;
2121
import java.net.URISyntaxException;
22+
import java.nio.file.Path;
2223
import java.text.SimpleDateFormat;
2324
import java.util.Date;
2425
import java.util.Map;
@@ -300,7 +301,18 @@ public CreateEntityDownloadURLAnswer handleCreateEntityURLCommand(CreateEntityDo
300301
logger.error(errorString);
301302
return new CreateEntityDownloadURLAnswer(errorString, CreateEntityDownloadURLAnswer.RESULT_FAILURE);
302303
}
303-
304+
File parentFolder = file.getParentFile();
305+
if (parentFolder != null && parentFolder.exists()) {
306+
Path folderPath = parentFolder.toPath();
307+
Script script = new Script(true, "chmod", 1440 * 1000, logger);
308+
script.add("755", folderPath.toString());
309+
result = script.execute();
310+
if (result != null) {
311+
String errMsg = "Unable to set permissions for " + folderPath + " due to " + result;
312+
logger.error(errMsg);
313+
throw new CloudRuntimeException(errMsg);
314+
}
315+
}
304316
return new CreateEntityDownloadURLAnswer("", CreateEntityDownloadURLAnswer.RESULT_SUCCESS);
305317

306318
}

0 commit comments

Comments
 (0)