Qt loading deleted/renamed file with Windows 10 -


i'm seeing weird behavior when running test install of qt program (tried using qt 5.5.1 , 7.0). haven't noticed issue when running in debug/development environment - see issue when installed "program files (x86)".

the issue is: i'm using qdiriterator find database files within "qstandardpaths::datalocation" locations , loading them in via sqlite. phantom files located in program files (x86)//library/.ndat i'm seeing files previous install (which have been deleted) , ones have been renamed, deleted, still show , readable in program. these "phantom" files have been blocking loading of up-to-date file. it's strange - wonder if has seen issue?

i'm running windows 10 home on ssd-based machine (if matters). same issue qt 5.5.1 , 5.7. i've replicated on different machine similar configuration.

any ideas?

here's summary of code:

qstringlist standardpaths = qstandardpaths::locateall(qstandardpaths::datalocation, "library", qstandardpaths::locatedirectory);  qstringlist filefilters; filefilters << "*.ndat";  foreach (const qstring &dir, standardpaths) {     qdiriterator iterator (dir, filefilters);     while (iterator.hasnext()) {         const qstring &filepath = iterator.next();         qstring databasename = qfileinfo(filepath).basename();         database_->open(filepath, basename); // function     } }  booldatamanager::open (const qstring &filepath, const qstring &connectionname) {     qsqldatabase    db = qsqldatabase::adddatabase("qsqlite", connectionname);     db.setdatabasename (filepath);     if (!db.open()) {         error(qstring("cannot open database %1 error %2")                         .arg(qfileinfo(filepath).basename())                         .arg(db.lasterror().text()));         printerror();         return false;     }     databasenames_.append(connectionname);     return true; } 

this code seems read in files don't exist anymore - , strangely, reads contents of old files have been overwritten in same spot. seems happen when files located within "program files" directory; not in user directory or what-not.

for example, version 1 of code had database called "database.dat" 10 entries. version 2 of install overwrote file file of same name 20 entries. version 2 of code finds database.dat file reads in older version 10 entries - weird!

update

it appears these "phantom" files stored at: c:\users/username/appdata/local/virtualstore/program files (x86)/program name/database.dat

my guess i'm opening file in program not read-only windows creates working copy in user-writable location. investigate.

the issue windows caching - think - 1 cant tell software doesn't provide way debug - such windows.

i've heard solution can solved (or @ least decreased) turning on "application experience" service -- still run time time, typically when doing many filesystem writes in short of time.

i dont know cause -- , i'm pretty sure nobody else or have been fixed.. far know there no fix (as of answer's date)

--

here's solution problems works 100% of time:

to avoid problem, append version number end of database's filename each time compile, in fact apppend files using

#define version 4.22.21  

and adding .append(qstring("%1").arg(version)); or something.

all have write quick code import necessary data old database or wherever, should have more or less anyways using database.

better avoid situations try , figure them out -- not mention have perfect revision system without trying.

update

since theres no use case, no code, , no information project, have guess @ trying -

qlist<datadir*> datadirectories; datadir* new_datadir;  qstringlist standardpaths = qstandardpaths::locateall(qstandardpaths::datalocation, "library", qstandardpaths::locatedirectory);  qstringlist filefilters; filefilters << "*.ndat";  foreach (const qstring &dir, standardpaths) {      qdiriterator iterator (dir, filefilters);     while (iterator.hasnext()) {         const qstring &filepath = iterator.next();           qstring databasename = qfileinfo(filepath).basename();            database_->open(filepath, basename); // function           /* database reading or writing , save results            *   qhash or this: */            database_->close(); // super important       } } 

Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -