mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-26 10:43:47 +08:00
Do not purge internal history if saving history to file fails
darcs-hash:20070120023347-ac50b-8e61c5f65cfca3ffdb6dd740fc32b91a975fdb87.gz
This commit is contained in:
parent
9c5fb0392d
commit
1a76f2ecb9
49
history.c
49
history.c
|
@ -1,5 +1,5 @@
|
|||
/** \file history.c
|
||||
History functions, part of the user interface.
|
||||
History functions, part of the user interface.
|
||||
*/
|
||||
#include "config.h"
|
||||
|
||||
|
@ -612,6 +612,8 @@ static void history_save_mode( void *n, history_mode_t *m )
|
|||
int has_new=0;
|
||||
wchar_t *tmp_name;
|
||||
|
||||
int ok = 1;
|
||||
|
||||
/*
|
||||
First check if there are any new entries to save. If not, then
|
||||
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" ) ) )
|
||||
{
|
||||
hash_table_t mine;
|
||||
int ok = 1;
|
||||
|
||||
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);
|
||||
|
||||
/*
|
||||
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;
|
||||
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;
|
||||
}
|
||||
|
||||
signal_unblock();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user