Ignore:
Timestamp:
2020-07-12T13:25:34+12:00 (4 years ago)
Author:
ak19
Message:

MetadataCSVPlugin doesn't like windows style slashes in the Filename column. This meant MetadataToCSV run from windows didn't generate a metadata.csv acceptable to MetaCSVPlug. Committing from Linux, will then need retest from Win client.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/gli/src/org/greenstone/gatherer/metadata/MetadataToCSV.java

    r34264 r34265  
    4646import org.apache.commons.csv.*;
    4747
    48 import org.greenstone.gatherer.util.SafeProcess;
    4948import org.greenstone.gatherer.DebugStream;
    5049import org.greenstone.gatherer.Dictionary;
     
    5251import org.greenstone.gatherer.metadata.MetadataValue;
    5352import org.greenstone.gatherer.metadata.MetadataXMLFileManager;
    54 
     53import org.greenstone.gatherer.util.SafeProcess;
     54import org.greenstone.gatherer.util.Utility;
    5555
    5656
     
    116116        return fullPath;
    117117    } else {
    118         return fullPath.substring(indexMatch+import_path_length);
     118        fullPath =  fullPath.substring(indexMatch+import_path_length);
     119        // MetadataCSVPlugin wants URL style slashes (forward slashes) not Windows backslashes
     120        // as file separator. But on Linux, backslashes have a different meaning in filepaths,
     121        // so must only replace \ with / if we're on Windows.
     122        if(Utility.isWindows()) {
     123        fullPath = fullPath.replace("\\", "/");
     124        }
     125        return fullPath;
    119126    }
    120127    }
     
    426433            String filename = field;
    427434            // TODO: filenames are stored relative to import folder, convert to full path for internal use?
     435            // Relative filepaths are stored with URL style slashes not OS specific slashes
     436            // For Windows, reconvert to \
     437            //File fullPathFile = new File(coll_importdir_path, filename); // would this work to
     438                         // create OS specific paths, even if filename has slashes the wrong way round for Windows?
     439            if(Utility.isWindows()) {
     440                filename = filename.replace("/", "\\");
     441            }
    428442            File fullPathFile = new File(coll_importdir_path + filename);
    429443            ///System.err.println("Found Filename meta: " + filename);
Note: See TracChangeset for help on using the changeset viewer.