diff --git a/dssi-vst-scanner.cpp b/dssi-vst-scanner.cpp index 9ecc7c6..37ee5bb 100644 --- a/dssi-vst-scanner.cpp +++ b/dssi-vst-scanner.cpp @@ -133,6 +133,9 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR cmdline, int cmdshow) } } + int version = int(RemotePluginVersion * 1000); + write(targetfd, &version, sizeof(int)); + HINSTANCE libHandle = 0; std::vector vstPath = Paths::getPath @@ -206,14 +209,28 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR cmdline, int cmdshow) struct stat st; if (!stat(cacheFileName.c_str(), &st)) { - haveCache = true; - } else { + int testfd = open(cacheFileName.c_str(), O_RDONLY); + if (testfd >= 0) { + int testVersion = 0; + if (read(testfd, &testVersion, sizeof(int)) == sizeof(int) && + testVersion == version) { + haveCache = true; + } else { + cerr << "dssi-vst-scanner: Cache version mismatch for file " + << cacheFileName << " (" << testVersion << ", wanted " + << version << ") - rewriting" << endl; + } + close(testfd); + } + } + if (!haveCache) { if ((fd = open(cacheFileName.c_str(), O_WRONLY | O_CREAT, 0644)) < 0) { cerr << "dssi-vst-scanner: Failed to open cache file " << cacheFileName; perror(" for writing"); fd = targetfd; } else { writingCache = true; + write(fd, &version, sizeof(int)); } } } @@ -352,9 +369,15 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR cmdline, int cmdshow) cerr << "dssi-vst-scanner: Failed to open cache file " << cacheFileName; perror("for reading"); } else { - unsigned char c; - while (read(fd, &c, 1) == 1) { - write(targetfd, &c, 1); + int testVersion = 0; + if (read(fd, &testVersion, sizeof(int)) != sizeof(int) || + testVersion != version) { + cerr << "dssi-vst-scanner: Internal error: cache file " << cacheFileName << " verified earlier, but now fails version test (" << testVersion << " != " << version << ")" << endl; + } else { + unsigned char c; + while (read(fd, &c, 1) == 1) { + write(targetfd, &c, 1); + } } close(fd); } diff --git a/remoteplugin.h b/remoteplugin.h index 848da49..b31ee49 100644 --- a/remoteplugin.h +++ b/remoteplugin.h @@ -8,7 +8,7 @@ #ifndef REMOTE_PLUGIN_H #define REMOTE_PLUGIN_H -static const float RemotePluginVersion = 0.8; +static const float RemotePluginVersion = 0.9; enum RemotePluginDebugLevel { RemotePluginDebugNone, diff --git a/remotevstclient.cpp b/remotevstclient.cpp index 9ef953c..dbc6ab3 100644 --- a/remotevstclient.cpp +++ b/remotevstclient.cpp @@ -207,6 +207,12 @@ RemoteVSTClient::queryPlugins(std::vector &plugins) try { char buffer[64]; + int version = 0; + + tryRead(fd, &version, sizeof(int)); + if (version != int(RemotePluginVersion * 1000)) { + throw ((std::string)"Plugin scanner version mismatch"); + } while (1) {