mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-06 08:51:14 -03:00
Do not purge internal history if saving history to file fails
darcs-hash:20070120023347-ac50b-8e61c5f65cfca3ffdb6dd740fc32b91a975fdb87.gz
This commit is contained in:
49
history.c
49
history.c
@@ -1,5 +1,5 @@
|
|||||||
/** \file history.c
|
/** \file history.c
|
||||||
History functions, part of the user interface.
|
History functions, part of the user interface.
|
||||||
*/
|
*/
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
@@ -612,6 +612,8 @@ static void history_save_mode( void *n, history_mode_t *m )
|
|||||||
int has_new=0;
|
int has_new=0;
|
||||||
wchar_t *tmp_name;
|
wchar_t *tmp_name;
|
||||||
|
|
||||||
|
int ok = 1;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
First check if there are any new entries to save. If not, then
|
First check if there are any new entries to save. If not, then
|
||||||
we can just return
|
we can just return
|
||||||
@@ -649,7 +651,6 @@ static void history_save_mode( void *n, history_mode_t *m )
|
|||||||
if( (out=wfopen( tmp_name, "w" ) ) )
|
if( (out=wfopen( tmp_name, "w" ) ) )
|
||||||
{
|
{
|
||||||
hash_table_t mine;
|
hash_table_t mine;
|
||||||
int ok = 1;
|
|
||||||
|
|
||||||
hash_init( &mine, &hash_item_func, &hash_item_cmp );
|
hash_init( &mine, &hash_item_func, &hash_item_cmp );
|
||||||
|
|
||||||
@@ -717,26 +718,32 @@ static void history_save_mode( void *n, history_mode_t *m )
|
|||||||
|
|
||||||
halloc_free( on_disk);
|
halloc_free( on_disk);
|
||||||
|
|
||||||
/*
|
if( ok )
|
||||||
Reset the history. The item_t entries created in this session
|
{
|
||||||
are not lost or dropped, they are stored in the session_item
|
|
||||||
hash table. On reload, they will be automatically inserted at
|
|
||||||
the end of the history list.
|
|
||||||
*/
|
|
||||||
|
|
||||||
if( m->mmap_start && (m->mmap_start != MAP_FAILED ) )
|
|
||||||
munmap( m->mmap_start, m->mmap_length );
|
|
||||||
|
|
||||||
al_truncate( &m->item, 0 );
|
|
||||||
al_truncate( &m->used, 0 );
|
|
||||||
m->pos = 0;
|
|
||||||
m->has_loaded = 0;
|
|
||||||
m->mmap_start=0;
|
|
||||||
m->mmap_length=0;
|
|
||||||
|
|
||||||
m->save_timestamp=time(0);
|
|
||||||
m->new_count = 0;
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Reset the history. The item_t entries created in this session
|
||||||
|
are not lost or dropped, they are stored in the session_item
|
||||||
|
hash table. On reload, they will be automatically inserted at
|
||||||
|
the end of the history list.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if( m->mmap_start && (m->mmap_start != MAP_FAILED ) )
|
||||||
|
{
|
||||||
|
munmap( m->mmap_start, m->mmap_length );
|
||||||
|
}
|
||||||
|
|
||||||
|
al_truncate( &m->item, 0 );
|
||||||
|
al_truncate( &m->used, 0 );
|
||||||
|
m->pos = 0;
|
||||||
|
m->has_loaded = 0;
|
||||||
|
m->mmap_start=0;
|
||||||
|
m->mmap_length=0;
|
||||||
|
|
||||||
|
m->save_timestamp=time(0);
|
||||||
|
m->new_count = 0;
|
||||||
|
}
|
||||||
|
|
||||||
signal_unblock();
|
signal_unblock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user