Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2018-03-26 11:02:28 +02:00
commit 4a7048f324

View File

@ -44,6 +44,7 @@ import java.time.ZoneId;
import java.util.List; import java.util.List;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONWriter; import org.json.JSONWriter;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -74,10 +75,6 @@ public class ProjectMetadataUtilities {
tempFile.renameTo(file); tempFile.renameTo(file);
} }
public static void saveTableSchema(Project project, File projectDir) throws JSONException, IOException {
}
protected static void saveToFile(IMetadata projectMeta, File metadataFile) throws JSONException, IOException { protected static void saveToFile(IMetadata projectMeta, File metadataFile) throws JSONException, IOException {
Writer writer = new OutputStreamWriter(new FileOutputStream(metadataFile)); Writer writer = new OutputStreamWriter(new FileOutputStream(metadataFile));
try { try {
@ -89,22 +86,34 @@ public class ProjectMetadataUtilities {
} }
static public ProjectMetadata load(File projectDir) { static public ProjectMetadata load(File projectDir) {
try { ProjectMetadata pm = null;
return loadFromFile(new File(projectDir, ProjectMetadata.DEFAULT_FILE_NAME));
} catch (Exception e) { pm = loadMetaDataIfExist(projectDir, ProjectMetadata.DEFAULT_FILE_NAME);
if (pm == null) {
pm = loadMetaDataIfExist(projectDir, ProjectMetadata.TEMP_FILE_NAME);
} }
try { if (pm == null) {
return loadFromFile(new File(projectDir, ProjectMetadata.TEMP_FILE_NAME)); pm = loadMetaDataIfExist(projectDir, ProjectMetadata.OLD_FILE_NAME);
} catch (Exception e) {
} }
try { return pm;
return loadFromFile(new File(projectDir, ProjectMetadata.OLD_FILE_NAME));
} catch (Exception e) {
} }
return null; private static ProjectMetadata loadMetaDataIfExist(File projectDir, String fileName) {
ProjectMetadata pm = null;
File file = new File(projectDir, fileName);
if (file.exists()) {
try {
pm = loadFromFile(file);
} catch (Exception e) {
logger.warn("load metadata failed: " + file.getAbsolutePath());
logger.error(ExceptionUtils.getStackTrace(e));
}
}
return pm;
} }
/** /**