def delete_user_file_in_hdfs(user): """ Remove user's all file in hdfs. """ file_set = user.upload_file.all() for item in enumerate(file_set): if item[1].file_type == 'FILE': hdfs_path = item[1].get_hdfs_path() username = user.username delete_object(username, hdfs_path)
def delete_user_file_in_hdfs(user): """ Remove user's all file in hdfs. """ file_set = user.upload_file.all() for item in enumerate(file_set): if item[1].file_type == "FILE": hdfs_path = item[1].get_hdfs_path() username = user.username delete_object(username, hdfs_path)
def remove_user_dir(sender, instance, **kwargs): """ Remove corresponding File instance and directory in hdfs when a user is deleted """ home_dir = get_home_dir(instance) delete_user_file_in_hdfs(instance) response = delete_object(instance.username, home_dir.get_hdfs_path()) print(response) home_dir.delete()
def perform_destroy(self, instance): """ Remove a file or directory in hdfs. """ username = self.request.user.username hdfs_path = instance.get_hdfs_path() response = delete_object(username, hdfs_path) if response != 'Remove object success': print("Remove fail!") raise serializers.ValidationError({'hdfs_path': response}) instance.delete()
def perform_destroy(self, instance): """ Remove a file or directory in hdfs. """ username = self.request.user.username hdfs_path = instance.get_hdfs_path() response = delete_object(username, hdfs_path) if response != 'Remove object success': print("Remove fail!") raise serializers.ValidationError({ 'hdfs_path': response }) instance.delete()