Patch level : 12.0 1186

Files correlati     : xvaga.dll

Commento:

Le cache di file si aggiornano meglio, abbiamo aggiornato la data di modifica dei file ad ogni srittura cion la nuova funzione xvt_fsys_set_file_time in xvaga.
le relapp per default aggiornano le cache di file
This commit is contained in:
Alessandro Bonazzi 2022-08-02 22:00:09 +02:00
parent 6bdaecf6f1
commit caa96b90e2
4 changed files with 22 additions and 13 deletions

View File

@ -956,7 +956,7 @@ int TBaseisamfile::_write(const TRectype& rec)
if (rec.has_memo())
((TRectype&)rec).write_memo(_isam_handle, _recno );
rec_cache(_logicnum).notify_change();
xvt_fsys_set_file_time(filename(), nullptr, nullptr, xvt_time_now());
}
else
_lasterr = get_error(_lasterr);
@ -1016,6 +1016,7 @@ int TBaseisamfile::_rewrite(const TRectype& rec)
{
memcpy(DB_getrecord(fhnd), rec.string(), len);
_lasterr = DB_rewrite(fhnd);
xvt_fsys_set_file_time(filename(), nullptr, nullptr, xvt_time_now());
if (_lasterr == NOERR)
rec_cache(_logicnum).notify_change();
else
@ -3801,7 +3802,9 @@ const TString& TRectype::get(const char* fieldname) const
if (orig)
{
CHECKD(orig >= LF_EXTERNAL || orig == num(), "Invalid isam handle ", orig);
TCodeb_handle cb_handle = prefix().get_handle(orig, -1);
CHECKD(cb_handle >= 0, "Can't read memo from file ", orig);
if (DB_recno(cb_handle) != _memo_data->recno())
DB_go(cb_handle, _memo_data->recno());
@ -3910,7 +3913,7 @@ void TRectype::put_str(const char* fieldname, const char* val)
const int nf = findfld(&recd, fieldname);
if (nf == FIELDERR)
{
unknown_field(fieldname);
unknown_field(fieldname);
return;
}
@ -3937,6 +3940,7 @@ void TRectype::put_str(const char* fieldname, const char* val)
__putfieldbuff(fd.Len, fd.Dec, ft, val, _rec + fd.RecOff);
}
setempty(FALSE);
}
@ -3959,7 +3963,7 @@ void TRectype::zero(const char* fieldname)
const RecDes& recd = rec_des();
const int nf = findfld(&recd, fieldname);
if (nf == FIELDERR)
unknown_field(fieldname);
unknown_field(fieldname);
else
{
const int recoff = recd.Fd[nf].RecOff;
@ -3974,7 +3978,7 @@ void TRectype::zero(const char* fieldname)
__putfieldbuff(len, dec, _datefld, "", p);
break;
case _memofld:
__putfieldbuff(len, dec, _memofld, "", p);
__putfieldbuff(len, dec, _memofld, "", p);
_memo_data->add("", nf);
_memo_data->set_dirty(nf);
break;

View File

@ -94,7 +94,7 @@ void TRecord_array::set_key(TRectype* r)
const RecDes& recd = r->rec_des(); // Descrizione del record della testata
const KeyDes& kd = recd.Ky[0]; // Elenco dei campi della chiave 1
// Copia tutti i campi chiave, tranne l'ultimo, in tutti i records
// Copia tutti i campi chiave, tranne l'ultimo, in tutti i records
TString80 val;
for (int i = kd.NkFields-2; i >= 0; i--)
{
@ -546,6 +546,7 @@ int TRecord_array::remove() const
unsigned long TFile_cache::_hits = 0;
unsigned long TFile_cache::_misses = 0;
bool TFile_cache::_global_test_changes = false;
void TFile_cache::stats(unsigned long& h, unsigned long& m)
{
@ -661,11 +662,11 @@ void TFile_cache::test_firm()
}
}
if (_test_changes && !_changed && _file != NULL)
if (check_changes() && !_changed && _file != nullptr)
{
// Non controllare troppo spesso la data del file nei programmi batch: aspetta almeno 2 secondi!
const unsigned long now = clock();
if (now > _last_file_test + 2500)
if (now > _last_file_test + (_global_test_changes ? 0 : 2500))
{
TFilename n = prefix().get_filename(_file->num()); n.ext("dbf");
FILE_SPEC fs; xvt_fsys_convert_str_to_fspec(n, &fs);
@ -677,7 +678,7 @@ void TFile_cache::test_firm()
}
}
const bool flush_needed = _test_changes && _changed && _file != NULL;
const bool flush_needed = check_changes() && _changed && _file != NULL;
if (flush_needed)
{
@ -720,7 +721,7 @@ const TObject& TFile_cache::query(const char* code)
TObject* obj = _cache.objptr(_code);
if (obj == NULL)
if (obj == nullptr)
{
TLocalisamfile& f = file();
TRectype& curr = f.curr();
@ -760,10 +761,7 @@ const TObject& TFile_cache::query(const char* code)
_misses++;
}
else
{
_hits++;
}
return *obj;
}

View File

@ -157,6 +157,7 @@ public:
class TFile_cache : public TObject
{
static unsigned long _hits, _misses;
static bool _global_test_changes;
TToken_string _code;
TString8 _filecode; // Codice tabella es: %STA, &AUT, LVCAU
@ -200,6 +201,8 @@ public:
void set_items_limit(long l) { _limit = l; }
void test_file_changes(bool t = TRUE) { _test_changes = t; }
static void global_file_changes(bool t = TRUE) { _global_test_changes = t; }
bool check_changes() const { return _global_test_changes || _test_changes; }
void notify_change();
static void stats(unsigned long& hits, unsigned long& misses);

View File

@ -214,6 +214,7 @@ void TRelation_application::set_find_button()
bool TRelation_application::create()
{
TFile_cache::global_file_changes(true);
bool ok = user_create();
if (ok)
{
@ -811,6 +812,7 @@ int TRelation_application::delete_mode()
TToken_string fldlist = brw->get_input_field_names();
TString80 str;
int fi = 0;
for (TString80 tok = inplist.get(fi); tok.not_empty(); tok = inplist.get(), fi++)
{
const TString16 fn = fldlist.get(fi);
@ -890,6 +892,7 @@ int TRelation_application::delete_mode()
TWait_cursor hourglass;
long skipped = 0; // Record non cancellati perche' protetti
cur.freeze(TRUE); // Congelo il cursore altrimenti si riaggiorna troppo
batch(true);
for (long pos = sht.items()-1; deleting > 0; pos--)
{
if (sht.checked(pos))
@ -919,7 +922,8 @@ int TRelation_application::delete_mode()
deleting--;
}
}
cur.freeze(false);
batch(false);
cur.freeze(false);
set_limits(); // Riaggiorno il numero del primo/ultimo record
if (skipped > 0)