Ejemplo n.º 1
0
static int stale_blob_examiner (const blockblob * bb)
{
    char work_path [MAX_PATH];
    
    set_path (work_path, sizeof (work_path), NULL, NULL);
    int work_path_len = strlen (work_path);
    assert (work_path_len > 0);

    char * s = strstr(bb->blocks_path, work_path);
    if (s==NULL || s!=bb->blocks_path)
        return 0; // blob not under work blobstore path

    // parse the path past the work directory base
    safe_strncpy (work_path, bb->blocks_path, sizeof (work_path));
    s = work_path + work_path_len + 1;
    char * user_id = strtok (s, "/");
    char * inst_id = strtok (NULL, "/"); 
    char * file    = strtok (NULL, "/");

    ncInstance * instance = find_instance (instances, inst_id);
    if (instance == NULL) { // not found among running instances => stale
        // while we're here, try to delete extra files that aren't managed by the blobstore
        // TODO: ensure we catch any other files - perhaps by performing this cleanup after all blobs are deleted
        char path [MAX_PATH];
#define del_file(filename) snprintf (path, sizeof (path), "%s/work/%s/%s/%s", instances_path, user_id, inst_id, filename); unlink (path);
        del_file("instance.xml");
        del_file("libvirt.xml");
        del_file("console.log");
        del_file("instance.checkpoint");
        return 1;
    }

    return 0;
}
Ejemplo n.º 2
0
int aos_closedir(aos_dir_t *dir)
{
    file_t  *f;
    inode_t *node;
    int err, ret = -ENOSYS;

    if (dir == NULL) {
        return -EINVAL;
    }

    f = get_file(dir->dd_vfs_fd);

    if (f == NULL) {
        return -ENOENT;
    }

    node = f->node;

    if (INODE_IS_FS(node)) {
        if ((node->ops.i_fops->closedir) != NULL) {
            ret = (node->ops.i_fops->closedir)(f, dir);
        }
    }

    if ((err = aos_mutex_lock(&g_vfs_mutex, AOS_WAIT_FOREVER)) != 0) {
        return err;
    }

    del_file(f);

    aos_mutex_unlock(&g_vfs_mutex);

    return ret;
}
Ejemplo n.º 3
0
/* This function is used to delete a file or directory specified by the
 * 'name' variable.  The type of 'name' is figured out.  If the recurse
 * option is TRUE, directories will be recursively emptied then deleted.
 * If force is TRUE, file attributes will be changed to allow the program
 * to delete the file.  The verbose option will cause non-fatal error messages
 * to print to stderr.  The quiet option will supress all but fatal
 * error messages
 */
BOOL del(wchar_t* name, BOOL recurse, BOOL force, BOOL verbose, BOOL quiet) {
    BOOL rv = TRUE;
    DWORD fileAttr = GetFileAttributesW(name);
    if (fileAttr == INVALID_FILE_ATTRIBUTES){
        rv = FALSE;
        if (!quiet) {
            fwprintf(stderr, L"Invalid file attributes for \"%ws\"\n", name);
        }
    } else if (fileAttr & FILE_ATTRIBUTE_DIRECTORY) {
        if (recurse){
            if (!empty_directory(name, force, verbose, quiet)){
                rv = FALSE;
            }
        } else {
            if (!del_directory(name, force, verbose, quiet)){
                rv = FALSE;
            }
        }
    } else {
        if (!del_file(name, force, verbose, quiet)){
            rv = FALSE;
        }
    }
    return rv;
}
Ejemplo n.º 4
0
int aos_open(const char *path, int flags)
{
    file_t  *file;
    inode_t *node;
    size_t len = 0;
    int ret = VFS_SUCCESS;

    if (path == NULL) {
        return -EINVAL;
    }

    len = strlen(path);
    if (len > PATH_MAX) {
        return -ENAMETOOLONG;
    }

    if ((ret = aos_mutex_lock(&g_vfs_mutex, AOS_WAIT_FOREVER)) != 0) {
        return ret;
    }

    node = inode_open(path);

    if (node == NULL) {
        aos_mutex_unlock(&g_vfs_mutex);
        return trap_open(path, flags);
    }

    node->i_flags = flags;
    file = new_file(node);

    aos_mutex_unlock(&g_vfs_mutex);

    if (file == NULL) {
        return -ENFILE;
    }

    if (INODE_IS_FS(node)) {
        if ((node->ops.i_fops->open) != NULL) {
            ret = (node->ops.i_fops->open)(file, path, flags);
        }

    } else {
        if ((node->ops.i_ops->open) != NULL) {
            ret = (node->ops.i_ops->open)(node, file);
        }
    }

    if (ret != VFS_SUCCESS) {
        del_file(file);
        return ret;
    }

    return get_fd(file);
}
Ejemplo n.º 5
0
/*递归删除文件夹*/
int del_file(int inode, char* name, int deepth)
{
	int 	child, i, t;
	Inode	temp;

	if (!strcmp(name, ".") || !strcmp(name, "..")) {
		/*不允许删除.和..*/
		printf("rmdir: failed to remove '%s': Invalid argument\n", name);
		return -1;
	}

	child = check_name(inode, name);

	/*读取当前子目录的Inode结构*/
	fseek(Disk, InodeBeg + sizeof(Inode)*child, SEEK_SET);
	fread(&temp, sizeof(Inode), 1, Disk);

	if (temp.type == File) {
		/*如果是文件则释放相应Inode即可*/
		free_inode(child);
		/*若是最上层文件,需调整目录*/
		if (deepth == 0) {
			adjust_dir(name);
		}
		return 1;
	}
	else {
		/*否则进入子目录*/
		enter_child_dir(inode, name);
	}

	for (i = 2; i<dir_num; ++i) {
		del_file(child, dir_table[i].name, deepth + 1);
	}

	enter_child_dir(child, "..");//返回上层目录
	free_inode(child);

	if (deepth == 0) {
		/*删除自身在目录中的内容*/
		if (dir_num / DirPerBlk != (dir_num - 1) / DirPerBlk) {
			/*有磁盘块可以释放*/
			curr_inode.blk_num--;
			t = curr_inode.blk_identifier[curr_inode.blk_num];
			free_blk(t);//释放相应的磁盘块
		}
		adjust_dir(name);//因为可能在非末尾处删除,因此要移动dir_table的内容
	}/*非初始目录直接释放Inode*/

	return 1;
}
Ejemplo n.º 6
0
static int del_file(direntry_t *entry, MainParam_t *mp)
{
	char shortname[13];
	direntry_t subEntry;
	Stream_t *SubDir;
	Arg_t *arg = (Arg_t *) mp->arg;
	MainParam_t sonmp;
	int ret;
	int r;	

	sonmp = *mp;
	sonmp.arg = mp->arg;

	r = 0;
	if (IS_DIR(entry)){
		/* a directory */		
		SubDir = OpenFileByDirentry(entry);
		initializeDirentry(&subEntry, SubDir);
		ret = 0;
		while((r=vfat_lookup(&subEntry, "*", 1,
				     ACCEPT_DIR | ACCEPT_PLAIN,
				     shortname, NULL)) == 0 ){
			if(shortname[0] != DELMARK &&
			   shortname[0] &&
			   shortname[0] != '.' ){
				if(arg->deltype != 2){
					fprintf(stderr,
						"Directory ");
					fprintPwd(stderr, entry,0);
					fprintf(stderr," non empty\n");
					ret = ERROR_ONE;
					break;
				}
				if(got_signal) {
					ret = ERROR_ONE;
					break;
				}
				ret = del_file(&subEntry, &sonmp);
				if( ret & ERROR_ONE)
					break;
				ret = 0;
			}
		}
		FREE(&SubDir);
		if (r == -2)
			return ERROR_ONE;
		if(ret)
			return ret;
	}
	return del_entry(entry, mp);
}
Ejemplo n.º 7
0
aos_dir_t *aos_opendir(const char *path)
{
    file_t  *file;
    inode_t *node;
    aos_dir_t *dp = NULL;

    if (path == NULL) {
        return NULL;
    }

    if (aos_mutex_lock(&g_vfs_mutex, AOS_WAIT_FOREVER) != 0) {
        return NULL;
    }

    node = inode_open(path);

    if (node == NULL) {
        aos_mutex_unlock(&g_vfs_mutex);
        return NULL;
    }

    file = new_file(node);

    aos_mutex_unlock(&g_vfs_mutex);

    if (file == NULL) {
        return NULL;
    }

    if (INODE_IS_FS(node)) {
        if ((node->ops.i_fops->opendir) != NULL) {
            dp = (node->ops.i_fops->opendir)(file, path);
        }
    }

    if (dp == NULL) {
        if (aos_mutex_lock(&g_vfs_mutex, AOS_WAIT_FOREVER) != 0) {
            return NULL;
        }

        del_file(file);

        aos_mutex_unlock(&g_vfs_mutex);
        return NULL;
    }

    dp->dd_vfs_fd = get_fd(file);
    return dp;
}
Ejemplo n.º 8
0
void Music::listMusic_customContextMenuRequested(const QPoint &pos)
{
    if(ui->listMusic->itemAt(pos) == NULL) return;

    QMenu *popMenu =new QMenu(this);
    popMenu->addAction("Delete");
    popMenu->addMenu(ui->menuFile);
    popMenu->addMenu(ui->menuPre);

    connect(popMenu->actions().at(0),SIGNAL(triggered()),this,SLOT(del_file()));

    popMenu->exec(QCursor::pos());//弹出右键菜单,菜单位置为光标位置
    popMenu->close();
    delete popMenu;
}
Ejemplo n.º 9
0
int aos_rename(const char *oldpath, const char *newpath)
{
    file_t  *f;
    inode_t *node;
    int err, ret = -ENOSYS;

    if (oldpath == NULL || newpath == NULL) {
        return -EINVAL;
    }

    if ((err = aos_mutex_lock(&g_vfs_mutex, AOS_WAIT_FOREVER)) != 0) {
        return err;
    }

    node = inode_open(oldpath);

    if (node == NULL) {
        aos_mutex_unlock(&g_vfs_mutex);
        return -ENODEV;
    }

    f = new_file(node);

    aos_mutex_unlock(&g_vfs_mutex);

    if (f == NULL) {
        return -ENOENT;
    }

    if (INODE_IS_FS(node)) {
        if ((node->ops.i_fops->rename) != NULL) {
            ret = (node->ops.i_fops->rename)(f, oldpath, newpath);
        }
    }

    if ((err = aos_mutex_lock(&g_vfs_mutex, AOS_WAIT_FOREVER)) != 0) {
        return err;
    }

    del_file(f);

    aos_mutex_unlock(&g_vfs_mutex);
    return ret;
}
Ejemplo n.º 10
0
int aos_mkdir(const char *path)
{
    file_t  *file;
    inode_t *node;
    int err, ret = -ENOSYS;

    if (path == NULL) {
        return -EINVAL;
    }

    if ((err = aos_mutex_lock(&g_vfs_mutex, AOS_WAIT_FOREVER)) != 0) {
        return err;
    }

    node = inode_open(path);

    if (node == NULL) {
        aos_mutex_unlock(&g_vfs_mutex);
        return -ENODEV;
    }

    file = new_file(node);

    aos_mutex_unlock(&g_vfs_mutex);

    if (file == NULL) {
        return -ENOENT;
    }

    if (INODE_IS_FS(node)) {
        if ((node->ops.i_fops->mkdir) != NULL) {
            ret = (node->ops.i_fops->mkdir)(file, path);
        }
    }

    if ((err = aos_mutex_lock(&g_vfs_mutex, AOS_WAIT_FOREVER)) != 0) {
        return err;
    }

    del_file(file);

    aos_mutex_unlock(&g_vfs_mutex);
    return ret;
}
Ejemplo n.º 11
0
void handle_request (int f)
{
    struct request r;

    printf ("Process %d, handling connection from %s\n",
            getpid(), get_callername (f));

    read(f, &r, sizeof(r));

    if (r.kind == REQUEST_PUT) {
        put_file(f, r.path, r.nbbytes);
    } else if (r.kind == REQUEST_DEL) {
        del_file(f, r.path);
    } else if (r.kind == REQUEST_DIR) {
        dir_file(f, r.path);
    } else {
        get_file(f, r.path);
    }
}
Ejemplo n.º 12
0
void DirContent::file_alt(FAMEvent *ev)
{
  std::string fn(ev->filename);
  //cout << "file event: " << ev->code << " / "<< event_name(ev->code) << endl;
  switch (ev->code)
  {
    case FAMCreated:
    {
      cout << "file : " << fn << " be created" << endl;
      if (is_dir(dirname() + "/" + fn) )
      {
	emit create_file(gen_items(fn, true) );
      }
      else
        gen_items(fn, false);
      break;
    }
    case FAMDeleted:
    {
      cout << "file : " << fn << " be deleted" << endl;
      del_items(fn);
      emit del_file(fn);
/*
      if (is_dir(dn_ + "/" + fn) )
      {
        cout << "emit del_file(fn)" << endl;
      }
      */
      break;
    }
    case FAMChanged:
    {
      cout << "file : " << dn_ << " be changed" << endl;
      break;
    }
    default:
    {
      //cout << "I don't care" << endl;
      break;
    }

  }
}
Ejemplo n.º 13
0
QString dbmanager::del(QString pageid)
{
    qDebug() <<"DELETION CODE GOES HERE";
    del_file(pageid);


    QDir dir(data_path);
    dir.cd("WTL_appdata");

    QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");//not dbConnection
    db.setDatabaseName(dir.absoluteFilePath("WTL.db"));
    if(!db.open())
    {
        qDebug() <<"error in opening DB";
    }
    else
    {
        qDebug() <<"connected to DB" ;

    }
    int revid ;
    QSqlQuery query;
    // every page and it's dependencies  has a revid associated with it .
    // revid is unique , used it to delete the pages

    query.prepare("Select page_revision from Pages where page_ID = :id");
    query.bindValue(":id", pageid);
    query.exec();

    if (query.next()) {
        revid = query.value(0).toInt();

    }
    db.close();

    del_from_db(pageid,revid);

    static auto i = 0;
    return QString("%1: %2").arg(++i).arg(pageid);

}
Ejemplo n.º 14
0
int aos_close(int fd)
{
    int ret = VFS_SUCCESS;
    file_t  *f;
    inode_t *node;

    f = get_file(fd);

    if (f == NULL) {
        return trap_close(fd);
    }

    node = f->node;

    if (INODE_IS_FS(node)) {
        if ((node->ops.i_fops->close) != NULL) {
            ret = (node->ops.i_fops->close)(f);
        }

    } else {

        if ((node->ops.i_ops->close) != NULL) {
            ret = (node->ops.i_ops->close)(f);
        }
    }

    if ((ret = aos_mutex_lock(&g_vfs_mutex, AOS_WAIT_FOREVER)) != 0) {
        return ret;
    }

    del_file(f);

    aos_mutex_unlock(&g_vfs_mutex);

    return ret;
}
Ejemplo n.º 15
0
int remove_file(int inode, char* name, int deepth, int type)
{
	char original_name_path[30];
	int original_inode = inode_num;//记录当前的inode

	strcpy(original_name_path, name);
	if (eat_path(name) == -1) {
		if (type == Directory)
			printf("rmdir: failed to remove‘%s’: No such file or directory\n", original_name_path);
		if (type == File)
			printf("rm: cannot remove‘%s’: No such file or directory\n", original_name_path);
		return -1;
	}

	int check_type_result = type_check(name);
	if (check_type_result == -1) {//要删除的文件不存在
		if (type == Directory)
			printf("rmdir: failed to remove '%s': No such file or directory\n", original_name_path);
		if (type == File)
			printf("rm: cannot remove '%s': No such file or directory\n", original_name_path);
		close_dir(inode_num);
		inode_num = original_inode;
		open_dir(inode_num);
		return -1;
	}

	Inode father_inode;
	/*读取要删除的目录或文件的父目录的Inode*/
	fseek(Disk, InodeBeg + sizeof(Inode)*inode_num, SEEK_SET);
	fread(&father_inode, sizeof(father_inode), 1, Disk);

	if (father_inode.access[1] == 0) { //要删除的目录或文件的父目录不允许写
		if (type == Directory)
			printf("rmdir: failed to remove ‘%s’: Permission denied\n", original_name_path);
		if (type == File)
			printf("rm: cannot remove‘%s’: Permission denied\n", original_name_path);
		close_dir(inode_num);
		inode_num = original_inode;
		open_dir(inode_num);
		return -1;
	}

	if (check_type_result == Directory && type == File) {//删除的文件类型与对应指令不符,如:尝试用rm删除目录
		printf("rm: cannot remove '%s': Not a file\n", original_name_path);
		close_dir(inode_num);
		inode_num = original_inode;
		open_dir(inode_num);
		return -1;
	}
	if (check_type_result == File && type == Directory) {//删除的文件类型与对应指令不符,如:用rmdir删除文件
		printf("rmdir: failed to remove '%s': Not a directory\n", original_name_path);
		close_dir(inode_num);
		inode_num = original_inode;
		open_dir(inode_num);
		return -1;
	}

	del_file(inode_num, name, 0);

	close_dir(inode_num);
	inode_num = original_inode;
	open_dir(inode_num);
	return 0;
}
Ejemplo n.º 16
0
Boolean 
info_lib::define_info_base( char* base_name, char* base_desc, 
                            char* spec_file_path
                          )
{
//MESSAGE(cerr, "define_info_base()");
//debug(cerr, base_name);
//debug(cerr, base_desc);
//debug(cerr, spec_file_path);

   char new_db_path[PATHSIZ]; 
   char f_name[PATHSIZ]; 
   char base_uid[UIDSIZ]; 

   strcpy(new_db_path, form("%s/%s", info_lib_path, base_name));

   strcpy(base_uid, unique_id());

   g_mode_8_3 = 1;

   info_base* base = get_info_base(base_name) ;

/* no checking here. DDK assures unique base name case
   if ( base == 0 ) {
*/
      
//////////////////////////
// check info base path
//////////////////////////
      if ( check_and_create_dir(new_db_path) == false ) {
         throw(stringException(form("bad base bath %s", new_db_path)));
      }

//////////////////////////
// remove any old files 
//////////////////////////

      strcpy(f_name, form("%s.%s", base_name, DATA_FILE_SUFFIX));
      if ( exist_file(f_name, new_db_path) == true )
         del_file(f_name, new_db_path);

      strcpy(f_name, form("%s.%s", base_name, INDEX_FILE_SUFFIX));
      if ( exist_file(f_name, new_db_path) == true )
         del_file(f_name, new_db_path);

      strcpy(f_name, form("%s.%s", base_name, SCHEMA_FILE_SUFFIX));
      if ( exist_file(f_name, new_db_path) == true )
         del_file(f_name, new_db_path);


      f_obj_dict -> init_a_base(spec_file_path, new_db_path, base_name);

      const char* lang;
      if ((lang = getenv("LC_ALL")) == NULL)
	if ((lang = getenv("LC_CTYPE")) == NULL)
	  if ((lang = getenv("LANG")) == NULL)
	    lang = "C";

#ifdef DtinfoClient
      _DtXlateDb db    = NULL;
      char* std_locale = NULL;

      if (_DtLcxOpenAllDbs(&db) == 0)
      {
	char platform[_DtPLATFORM_MAX_LEN + 1];
	int execver, compver;

	if (_DtXlateGetXlateEnv(db, platform, &execver, &compver) == 0)
	{
	  _DtLcxXlateOpToStd(db, platform, compver, DtLCX_OPER_SETLOCALE,
					lang, &std_locale, NULL, NULL, NULL);
	}
	_DtLcxCloseDb(&db);
	db = NULL;
      }
#endif

      base = new info_base(*f_obj_dict, set_nm_list, list_nm_list,
                           new_db_path, base_name, base_desc, base_uid,
#ifdef DtinfoClient
			   std_locale ? std_locale : lang,
#else
			   lang,
#endif
                           mm_version(MAJOR, MINOR)
                          );

      info_base_list.insert_as_tail(new dlist_void_ptr_cell(base));

/*************************************/
// add the base name and description
// to the names file
/*************************************/
      char* lib_nm = form("%s/%s", info_lib_path, MAP_FILE_8_3);

      fstream nm_out(lib_nm, ios::app, open_file_prot());

      if ( !nm_out ) {
         MESSAGE(cerr, form("can't open %s/%s for append", 
                            info_lib_path, MAP_FILE_8_3)
                );
         throw(streamException(nm_out.rdstate()));
      }

      if ( bytes(nm_out) == 0 ) {
         char* lib_entry = form("%s\t%s\n", info_lib_name, unique_id());

         if ( !(nm_out << lib_entry) ) {
            MESSAGE(cerr, 
	       form("write %s.%s failed", info_lib_path, MAP_FILE_8_3));
            throw(streamException(nm_out.rdstate()));
         }
      }

      char* base_entry = form("%s\t%s\t%s\t%s\t%d\t%d\n", 
                              base_name, base_desc, base_uid,
#ifdef DtinfoClient
			      std_locale ? std_locale: lang,
#else
			      lang,
#endif
			      MAJOR, MINOR
                             );
#ifdef DtinfoClient
      if (std_locale)
	free(std_locale);
#endif

      if ( !(nm_out << base_entry) ) {
         MESSAGE(cerr, form("write %s.%s failed", info_lib_path, MAP_FILE_8_3));
         throw(streamException(nm_out.rdstate()));
      }

      nm_out.close();

      if ( nm_out.fail() ) {
         MESSAGE(cerr, form("close %s.%s failed", info_lib_path, MAP_FILE_8_3));
         throw(streamException(nm_out.rdstate()));
      }

   //}


//MESSAGE(cerr, "define() done");
   return true;
}
Ejemplo n.º 17
0
/* This function will recursively remove all files in a directory
 * then the directory itself.
 */
BOOL empty_directory(wchar_t* name, BOOL force, BOOL verbose, BOOL quiet){
    BOOL rv = TRUE;
    DWORD ffStatus;
    WIN32_FIND_DATAW findFileData;
    // TODO: Don't waste so much memory!
    wchar_t dir[MAX_PATH];
    HANDLE hFind = INVALID_HANDLE_VALUE;
	// Used while disabling Wow64 FS Redirection
	//Unused for now PVOID* wow64value = NULL;

    /* without a trailing \*, the listing for "c:\windows" would show info
     * for "c:\windows", not files *inside* of "c:\windows"
     */
    StringCchCopyW(dir, MAX_PATH, name); // TODO: Check return
    StringCchCatW(dir, MAX_PATH, L"\\*");

    /* We don't know what's going on, but Wow64 redirection
     * is not working quite right.  Since nothing we have should
     * be in a location that needs Wow64, we should be fine to
     * ignore it
     */
    //Wow64DisableWow64FsRedirection(wow64value);

    hFind = FindFirstFileW(dir, &findFileData);

    if (hFind == INVALID_HANDLE_VALUE) {
        rv = FALSE;
        if (!quiet) {
            print_error(GetLastError(), name, stderr);
        }
        return rv;
    }

    do {
        wchar_t fullName[MAX_PATH];
        StringCchCopyW(fullName, MAX_PATH, name);
        StringCchCatW(fullName, MAX_PATH, L"\\");
        StringCchCatW(fullName, MAX_PATH, findFileData.cFileName);
        if (findFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
            if (wcscmp(L".", findFileData.cFileName) != 0 && wcscmp(L"..", findFileData.cFileName) != 0){
                if (!empty_directory(fullName, force, verbose, quiet)){
                    rv = FALSE;
                }
            }
        } else {
            if (!del_file(fullName, force, verbose, quiet)) {
                rv = FALSE;
            }
        }
    } while (FindNextFileW(hFind, &findFileData) != 0);

    /* if (!Wow64RevertWow64FsRedirection(wow64value)) {
     *    if (!quiet) {
     *        fwprintf(stderr, L"Error restoring Wow64 FS Redirection\n");
     *    }
     *    return FALSE;
     * }
     */

    ffStatus = GetLastError();
    if (ffStatus != ERROR_NO_MORE_FILES) {
        print_error(ffStatus, findFileData.cFileName, stderr);
        rv = FALSE;
    }

    FindClose(hFind);

    del_directory(name, force, verbose, quiet);

    return rv;

}
Ejemplo n.º 18
0
/*
**  del_log
*/
STATUS
del_log()
{
    return (del_file(logname));
}
Ejemplo n.º 19
0
bool check_revision(QString id , int revision_number)
{
    int pageid;

    QEventLoop eventLoop;

    // "quit()" the event-loop, when the network request "finished()"
    QNetworkAccessManager mg;
    QObject::connect(&mg, SIGNAL(finished(QNetworkReply*)), &eventLoop, SLOT(quit()));

    // the HTTP request
    QString url = "http://en.wikitolearn.org/api.php?action=parse&pageid="+id+"&format=json";
    QNetworkRequest re( ( url ) );
    QNetworkReply *reply = mg.get(re);
    eventLoop.exec();

    if (reply->error() == QNetworkReply::NoError) {
        //success
        //qDebug() << "Success" <<reply->readAll();
        QString   html = (QString)reply->readAll();
        QJsonDocument jsonResponse = QJsonDocument::fromJson(html.toUtf8());

        QJsonObject jsonObj = jsonResponse.object();

        int  revid = jsonObj["parse"].toObject()["revid"].toInt();
        pageid = jsonObj["parse"].toObject()["pageid"].toInt();
        QString page_title = jsonObj["parse"].toObject()["title"].toString();
        qDebug() << jsonObj["parse"].toObject()["title"].toString();


        if(revision_number == revid)
        {
            delete reply;
            return true ;
        }
        else
        {
            qDebug() << "update page";
            QString text = jsonObj["parse"].toObject()["text"].toObject()["*"].toString();
            text = clean_text(text);
            bool del = del_from_db(id,revid);
            //check if deletion was successfull
            if(del == true)
            {
                qDebug() << "deletion from DB done";
            }
            else
            {
                qDebug() << "error in deletion from DB";
            }
            QString pid = QString::number(pageid);
            del_file(pid);
            save_file( text ,  pageid ,  revision_number , page_title);


        }

    }

    return true;

}