Lazy unmount, umount (macOS) support

This commit is contained in:
Arun Prakash Jana 2020-01-23 01:49:04 +05:30
parent d224016011
commit de4b817998
No known key found for this signature in database
GPG key ID: A75979F35C080412
2 changed files with 39 additions and 16 deletions

View file

@ -78,7 +78,7 @@ It runs smoothly on the Pi, [Termux](https://www.youtube.com/watch?v=AbaauM7gUJw
- Cross-dir file/all/range selection - Cross-dir file/all/range selection
- Batch renamer (feature-limited) for selection or dir - Batch renamer (feature-limited) for selection or dir
- Copy (as), move (as), delete, archive, link selection - Copy (as), move (as), delete, archive, link selection
- Notification on cp, mv, rm completion - Dir updates, notification on cp, mv, rm completion
- Copy file paths to system clipboard on select - Copy file paths to system clipboard on select
- Create (with parents), rename, duplicate (anywhere) files and dirs - Create (with parents), rename, duplicate (anywhere) files and dirs
- Launch GUI apps, run commands, spawn a shell, toggle executable - Launch GUI apps, run commands, spawn a shell, toggle executable

View file

@ -473,8 +473,9 @@ static char * const utils[] = {
#define MSG_BOOKMARK_KEYS 35 #define MSG_BOOKMARK_KEYS 35
#define MSG_INVALID_REG 36 #define MSG_INVALID_REG 36
#define MSG_ORDER 37 #define MSG_ORDER 37
#define MSG_LAZY 38
#ifndef DIR_LIMITED_SELECTION #ifndef DIR_LIMITED_SELECTION
#define MSG_DIR_CHANGED 38 /* Must be the last entry */ #define MSG_DIR_CHANGED 39 /* Must be the last entry */
#endif #endif
static const char * const messages[] = { static const char * const messages[] = {
@ -516,6 +517,7 @@ static const char * const messages[] = {
"bookmark keys:", "bookmark keys:",
"invalid regex", "invalid regex",
"toggle 'a'u / 'd'u / 'e'xtn / 'r'everse / 's'ize / 't'ime / 'v'ersion?", "toggle 'a'u / 'd'u / 'e'xtn / 'r'everse / 's'ize / 't'ime / 'v'ersion?",
"unmount failed! try lazy?",
#ifndef DIR_LIMITED_SELECTION #ifndef DIR_LIMITED_SELECTION
"dir changed, range sel off", /* Must be the last entry */ "dir changed, range sel off", /* Must be the last entry */
#endif #endif
@ -3518,18 +3520,24 @@ static bool remote_mount(char *newpath, int *presel)
*/ */
static bool unmount(char *name, char *newpath, int *presel, char *currentpath) static bool unmount(char *name, char *newpath, int *presel, char *currentpath)
{ {
#ifdef __APPLE__
static char cmd[] = "umount";
#else
static char cmd[] = "fusermount3"; /* Arch Linux utility */ static char cmd[] = "fusermount3"; /* Arch Linux utility */
static bool found = FALSE; static bool found = FALSE;
#endif
char *tmp = name; char *tmp = name;
struct stat sb, psb; struct stat sb, psb;
bool child = FALSE; bool child = FALSE;
bool parent = FALSE; bool parent = FALSE;
#ifndef __APPLE__
/* On Ubuntu it's fusermount */ /* On Ubuntu it's fusermount */
if (!found && !getutil(cmd)) { if (!found && !getutil(cmd)) {
cmd[10] = '\0'; cmd[10] = '\0';
found = TRUE; found = TRUE;
} }
#endif
if (tmp && strcmp(cfgdir, currentpath) == 0) { if (tmp && strcmp(cfgdir, currentpath) == 0) {
mkpath(cfgdir, tmp, newpath); mkpath(cfgdir, tmp, newpath);
@ -3554,10 +3562,25 @@ static bool unmount(char *name, char *newpath, int *presel, char *currentpath)
return FALSE; return FALSE;
} }
#ifdef __APPLE__
if (spawn(cmd, newpath, NULL, NULL, F_NORMAL)) {
#else
if (spawn(cmd, "-u", newpath, NULL, F_NORMAL)) { if (spawn(cmd, "-u", newpath, NULL, F_NORMAL)) {
#endif
int r = get_input(messages[MSG_LAZY]);
if (r != 'y' && r != 'Y')
return FALSE;
#ifdef __APPLE__
if (spawn(cmd, "-l", newpath, NULL, F_NORMAL)) {
#else
if (spawn(cmd, "-uz", newpath, NULL, F_NORMAL)) {
#endif
printwait(messages[MSG_FAILED], presel); printwait(messages[MSG_FAILED], presel);
return FALSE; return FALSE;
} }
}
return TRUE; return TRUE;
} }
@ -5877,16 +5900,8 @@ int main(int argc, char *argv[])
char *session = NULL; char *session = NULL;
int opt; int opt;
while ((opt = getopt(argc, argv, "HSKaAb:cdeEgnop:QrRs:t:vVxh")) != -1) { while ((opt = getopt(argc, argv, "aAb:cdeEgHKnop:QrRs:St:vVxh")) != -1) {
switch (opt) { switch (opt) {
case 'S':
cfg.blkorder = 1;
nftw_fn = sum_bsize;
blk_shift = ffs(S_BLKSIZE) - 1; // fallthrough
case 'd':
cfg.showdetail = 1;
printptr = &printent_long;
break;
case 'a': case 'a':
cfg.mtime = 0; cfg.mtime = 0;
break; break;
@ -5899,6 +5914,14 @@ int main(int argc, char *argv[])
case 'c': case 'c':
cfg.cliopener = 1; cfg.cliopener = 1;
break; break;
case 'S':
cfg.blkorder = 1;
nftw_fn = sum_bsize;
blk_shift = ffs(S_BLKSIZE) - 1; // fallthrough
case 'd':
cfg.showdetail = 1;
printptr = &printent_long;
break;
case 'e': case 'e':
cfg.useeditor = 1; cfg.useeditor = 1;
break; break;
@ -5912,6 +5935,9 @@ int main(int argc, char *argv[])
case 'H': case 'H':
cfg.showhidden = 1; cfg.showhidden = 1;
break; break;
case 'K':
check_key_collision();
return _SUCCESS;
case 'n': case 'n':
cfg.filtermode = 1; cfg.filtermode = 1;
break; break;
@ -5953,9 +5979,6 @@ int main(int argc, char *argv[])
case 't': case 't':
idletimeout = xatoi(optarg); idletimeout = xatoi(optarg);
break; break;
case 'K':
check_key_collision();
return _SUCCESS;
case 'v': case 'v':
namecmpfn = &xstrverscasecmp; namecmpfn = &xstrverscasecmp;
break; break;