Commit 6cdb5f97 authored by jan.koester's avatar jan.koester
Browse files

test

parent d8040697
Loading
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -131,7 +131,6 @@ namespace authdb{
        void write(const unsigned char *dest,size_t destsize);
        void read(char unsigned *src,size_t srcsize);

        friend class Domain;
        friend class RecordIndex;
        friend class DomainBackend;
        friend class Export;
+19 −1
Original line number Diff line number Diff line
@@ -43,7 +43,7 @@

#include "file.h"

authdb::File::File(const char* path,size_t version,const char *domain){
authdb::File::File(const char* path,size_t version,const char *domain) : _filePath(path) {
#ifdef Windows
    // Attempt to open the file.
    _FileDes = INVALID_HANDLE_VALUE;
@@ -619,3 +619,21 @@ void authdb::File::vacuum(){
    ::write(_FileDes, &head, sizeof(head));
#endif
}

void authdb::File::purge(){
#ifdef Windows
    if(_FileDes != INVALID_HANDLE_VALUE){
        CloseHandle(_FileDes);
        _FileDes = INVALID_HANDLE_VALUE;
    }
    DeleteFileA(_filePath.c_str());
    DeleteFileA(_lockFile.c_str());
#else
    if(_FileDes >= 0){
        close(_FileDes);
        _FileDes = -1;
    }
    unlink(_filePath.c_str());
    unlink(_lockFile.c_str());
#endif
}
+2 −0
Original line number Diff line number Diff line
@@ -63,7 +63,9 @@ namespace authdb {
        void newRevesion();

        void vacuum();
        void purge() override;
    private:
        std::string  _filePath;
        std::string  _lockFile;
        
#ifdef Windows
+0 −25
Original line number Diff line number Diff line
@@ -90,32 +90,7 @@ void authdb::Domain::create(authdb::AuthBackend& backend,class DomainData *data)
}

void authdb::Domain::remove(AuthBackend& backend, const uuid::uuid &uid){
     AuthBackend::Guard guard(backend);
     authdb::AuthData::Record cur;

    size_t rd=sizeof(authdb::AuthHeader),end=backend.end();

    while(rd+sizeof(AuthData::Record)<=end){
        backend.setPos(rd);
        backend.read((unsigned char*)&cur,sizeof(AuthData::Record));
        size_t next=backend.getPos()+cur.datasize;
        if(next<backend.getPos() || next>end) break;
        rd=next;
        if( uid==cur.ruid &&
            cur.type==DataType::DomainData &&
            strcmp(cur.fieldname,"domainoptions")==0){

            cur.data=new char[cur.datasize];
            backend.read((unsigned char*)cur.data,cur.datasize);

            unlink(cur.data);

            delete[] cur.data;
        }
    }

    backend.delRecord(uid,DataType::DomainData);

}