kevinw66 commented on code in PR #3365: URL: https://github.com/apache/ambari/pull/3365#discussion_r989242960
########## ambari-common/src/main/python/resource_management/libraries/providers/hdfs_resource.py: ########## @@ -524,29 +524,33 @@ def _create_file(self, target, source=None, mode=""): file_status = self._get_file_status(target) if target!=self.main_resource.resource.target else self.target_status mode = "" if not mode else mode + kwargs = {'permission': mode} if mode else {} if file_status: + # Target file exists if source: + # Upload target file length = file_status['length'] local_file_size = os.stat(source).st_size # TODO: os -> sudo # TODO: re-implement this using checksums if local_file_size == length: Logger.info(format("DFS file {target} is identical to {source}, skipping the copying")) - return elif not self.main_resource.resource.replace_existing_files: Logger.info(format("Not replacing existing DFS file {target} which is different from {source}, due to replace_existing_files=False")) - return + else: + Logger.info(format("Reupload file {target} in DFS")) + + self.util.run_command(target, 'CREATE', method='PUT', overwrite=True, assertable_result=False, file_to_put=source, **kwargs) + # Get file status again after file reupload + self.target_status = self._get_file_status(target) Review Comment: We cannot reassign `self.target_status` here. Because when we create a directory, the `target_status` represents the directory status, if we reassign this variable here, we will get the latest file status we uploaded -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@ambari.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@ambari.apache.org For additional commands, e-mail: dev-h...@ambari.apache.org