/*
 * Copyright 2016 the original author or authors.
 *
 * Licensed 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.gradle.api.internal.changedetection.state;

import org.gradle.api.internal.changedetection.state.mirror.PhysicalSnapshot;
import org.gradle.internal.file.FileType;
import org.gradle.internal.hash.HashCode;

public class DefaultNormalizedFileSnapshot extends AbstractNormalizedFileSnapshot {
    private final String normalizedPath;

    public DefaultNormalizedFileSnapshot(String normalizedPath, FileType type, HashCode contentHash) {
        super(type, contentHash);
        this.normalizedPath = normalizedPath;
    }

    public DefaultNormalizedFileSnapshot(String normalizedPath, PhysicalSnapshot snapshot) {
        this(normalizedPath, snapshot.getType(), snapshot.getType() == FileType.Directory ? DIR_SIGNATURE : snapshot.getHash());
    }

    @Override
    public String getNormalizedPath() {
        return normalizedPath;
    }
}

@@ -1077,16 +1077,34 @@
 er(type,
+ hashForType(type,
  content
@@ -1108,16 +1108,17 @@
 entHash)
+)
 ;%0A      
@@ -1322,75 +1322,439 @@
 .get
-Type() == FileType.Directory ? DIR_SIGNATURE : snapshot.getHash());
+Hash());%0A    %7D%0A%0A    private static HashCode hashForType(FileType fileType, HashCode hash) %7B%0A        switch (fileType) %7B%0A            case Directory:%0A                return DIR_SIGNATURE;%0A            case Missing:%0A                return MISSING_FILE_SIGNATURE;%0A            case RegularFile:%0A                return hash;%0A            default:%0A                throw new IllegalStateException(%22Unknown file type: %22 + fileType);%0A        %7D
 %0A   

Use correct hash for missing files