Merge pull request #17138 from simedis/import_md5
Make md5's not be in the same file as the import settings
This commit is contained in:
commit
bd82fc19e9
1 changed files with 51 additions and 12 deletions
|
@ -321,10 +321,10 @@ bool EditorFileSystem::_test_for_reimport(const String &p_path, bool p_only_impo
|
||||||
|
|
||||||
List<String> to_check;
|
List<String> to_check;
|
||||||
|
|
||||||
String source_file;
|
String source_file = "";
|
||||||
String source_md5;
|
String source_md5 = "";
|
||||||
Vector<String> dest_files;
|
Vector<String> dest_files;
|
||||||
String dest_md5;
|
String dest_md5 = "";
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|
||||||
|
@ -334,7 +334,6 @@ bool EditorFileSystem::_test_for_reimport(const String &p_path, bool p_only_impo
|
||||||
|
|
||||||
err = VariantParser::parse_tag_assign_eof(&stream, lines, error_text, next_tag, assign, value, NULL, true);
|
err = VariantParser::parse_tag_assign_eof(&stream, lines, error_text, next_tag, assign, value, NULL, true);
|
||||||
if (err == ERR_FILE_EOF) {
|
if (err == ERR_FILE_EOF) {
|
||||||
memdelete(f);
|
|
||||||
break;
|
break;
|
||||||
} else if (err != OK) {
|
} else if (err != OK) {
|
||||||
ERR_PRINTS("ResourceFormatImporter::load - " + p_path + ".import:" + itos(lines) + " error: " + error_text);
|
ERR_PRINTS("ResourceFormatImporter::load - " + p_path + ".import:" + itos(lines) + " error: " + error_text);
|
||||||
|
@ -351,12 +350,8 @@ bool EditorFileSystem::_test_for_reimport(const String &p_path, bool p_only_impo
|
||||||
to_check.push_back(fa[i]);
|
to_check.push_back(fa[i]);
|
||||||
}
|
}
|
||||||
} else if (!p_only_imported_files) {
|
} else if (!p_only_imported_files) {
|
||||||
if (assign == "source_md5") {
|
if (assign == "source_file") {
|
||||||
source_md5 = value;
|
|
||||||
} else if (assign == "source_file") {
|
|
||||||
source_file = value;
|
source_file = value;
|
||||||
} else if (assign == "dest_md5") {
|
|
||||||
dest_md5 = value;
|
|
||||||
} else if (assign == "dest_files") {
|
} else if (assign == "dest_files") {
|
||||||
dest_files = value;
|
dest_files = value;
|
||||||
}
|
}
|
||||||
|
@ -369,6 +364,42 @@ bool EditorFileSystem::_test_for_reimport(const String &p_path, bool p_only_impo
|
||||||
|
|
||||||
memdelete(f);
|
memdelete(f);
|
||||||
|
|
||||||
|
// Read the md5's from a separate file (so the import parameters aren't dependant on the file version
|
||||||
|
String base_path = ResourceFormatImporter::get_singleton()->get_import_base_path(p_path);
|
||||||
|
FileAccess *md5s = FileAccess::open(base_path + ".md5", FileAccess::READ, &err);
|
||||||
|
if (!md5s) { // No md5's stored for this resource
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
VariantParser::StreamFile md5_stream;
|
||||||
|
md5_stream.f = md5s;
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
assign = Variant();
|
||||||
|
next_tag.fields.clear();
|
||||||
|
next_tag.name = String();
|
||||||
|
|
||||||
|
err = VariantParser::parse_tag_assign_eof(&md5_stream, lines, error_text, next_tag, assign, value, NULL, true);
|
||||||
|
|
||||||
|
if (err == ERR_FILE_EOF) {
|
||||||
|
break;
|
||||||
|
} else if (err != OK) {
|
||||||
|
ERR_PRINTS("ResourceFormatImporter::load - " + p_path + ".import.md5:" + itos(lines) + " error: " + error_text);
|
||||||
|
memdelete(md5s);
|
||||||
|
return false; // parse error
|
||||||
|
}
|
||||||
|
if (assign != String()) {
|
||||||
|
if (!p_only_imported_files) {
|
||||||
|
if (assign == "source_md5") {
|
||||||
|
source_md5 = value;
|
||||||
|
} else if (assign == "dest_md5") {
|
||||||
|
dest_md5 = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
memdelete(md5s);
|
||||||
|
|
||||||
//imported files are gone, reimport
|
//imported files are gone, reimport
|
||||||
for (List<String>::Element *E = to_check.front(); E; E = E->next()) {
|
for (List<String>::Element *E = to_check.front(); E; E = E->next()) {
|
||||||
if (!FileAccess::exists(E->get())) {
|
if (!FileAccess::exists(E->get())) {
|
||||||
|
@ -1459,15 +1490,13 @@ void EditorFileSystem::_reimport_file(const String &p_file) {
|
||||||
}
|
}
|
||||||
|
|
||||||
f->store_line("source_file=" + Variant(p_file).get_construct_string());
|
f->store_line("source_file=" + Variant(p_file).get_construct_string());
|
||||||
f->store_line("source_md5=\"" + FileAccess::get_md5(p_file) + "\"\n");
|
|
||||||
|
|
||||||
if (dest_paths.size()) {
|
if (dest_paths.size()) {
|
||||||
Array dp;
|
Array dp;
|
||||||
for (int i = 0; i < dest_paths.size(); i++) {
|
for (int i = 0; i < dest_paths.size(); i++) {
|
||||||
dp.push_back(dest_paths[i]);
|
dp.push_back(dest_paths[i]);
|
||||||
}
|
}
|
||||||
f->store_line("dest_files=" + Variant(dp).get_construct_string());
|
f->store_line("dest_files=" + Variant(dp).get_construct_string() + "\n");
|
||||||
f->store_line("dest_md5=\"" + FileAccess::get_multiple_md5(dest_paths) + "\"\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
f->store_line("[params]");
|
f->store_line("[params]");
|
||||||
|
@ -1486,6 +1515,16 @@ void EditorFileSystem::_reimport_file(const String &p_file) {
|
||||||
f->close();
|
f->close();
|
||||||
memdelete(f);
|
memdelete(f);
|
||||||
|
|
||||||
|
// Store the md5's of the various files. These are stored separately so that the .import files can be version controlled.
|
||||||
|
FileAccess *md5s = FileAccess::open(base_path + ".md5", FileAccess::WRITE);
|
||||||
|
ERR_FAIL_COND(!md5s);
|
||||||
|
md5s->store_line("source_md5=\"" + FileAccess::get_md5(p_file) + "\"");
|
||||||
|
if (dest_paths.size()) {
|
||||||
|
md5s->store_line("dest_md5=\"" + FileAccess::get_multiple_md5(dest_paths) + "\"\n");
|
||||||
|
}
|
||||||
|
md5s->close();
|
||||||
|
memdelete(md5s);
|
||||||
|
|
||||||
//update modified times, to avoid reimport
|
//update modified times, to avoid reimport
|
||||||
fs->files[cpos]->modified_time = FileAccess::get_modified_time(p_file);
|
fs->files[cpos]->modified_time = FileAccess::get_modified_time(p_file);
|
||||||
fs->files[cpos]->import_modified_time = FileAccess::get_modified_time(p_file + ".import");
|
fs->files[cpos]->import_modified_time = FileAccess::get_modified_time(p_file + ".import");
|
||||||
|
|
Loading…
Reference in a new issue