briansolo1985 commented on code in PR #8898: URL: https://github.com/apache/nifi/pull/8898#discussion_r1629279887
########## minifi/minifi-nar-bundles/minifi-framework-bundle/minifi-framework/minifi-framework-core/src/main/java/org/apache/nifi/minifi/c2/command/syncresource/FileResourceRepository.java: ########## @@ -0,0 +1,123 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.nifi.minifi.c2.command.syncresource; + +import static java.nio.file.Files.exists; +import static java.nio.file.Files.readString; +import static java.nio.file.Files.writeString; +import static java.nio.file.StandardOpenOption.CREATE; +import static java.nio.file.StandardOpenOption.SYNC; +import static java.nio.file.StandardOpenOption.TRUNCATE_EXISTING; +import static java.nio.file.StandardOpenOption.WRITE; +import static java.util.stream.Collectors.toList; + +import java.io.IOException; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.List; +import org.apache.nifi.c2.protocol.api.ResourceItem; +import org.apache.nifi.c2.protocol.api.ResourcesGlobalHash; +import org.apache.nifi.c2.serializer.C2Serializer; + +public class FileResourceRepository implements ResourceRepository { + + static final String RESOURCE_REPOSITORY_FILE_NAME = "resources.json"; + + private static final ResourceRepositoryDescriptor EMTPY_HOLDER = new ResourceRepositoryDescriptor(new ResourcesGlobalHash(), List.of()); + + private final Path resourceRepositoryFile; + private final C2Serializer c2Serializer; + + private ResourceRepositoryDescriptor resourceRepositoryDescriptor; + + public FileResourceRepository(Path configDirectory, C2Serializer c2Serializer) { Review Comment: Intentionally left out the self healing, it would have made the PR bulky and too complex. The design allows to implement such logic, and we can think about implementing it within a new PR. As for the second issue - don't download file if it's already present, but the metadata is missing - I added the functionality and covered with tests -- 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: issues-unsubscr...@nifi.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org