Skip to content

Commit

Permalink
fix: The mounted Samba network disk prompts that the file has been mo…
Browse files Browse the repository at this point in the history
…ved or deleted after the user changes their password

Handle EHOSTDOWN errors

Log: The mounted Samba network disk prompts that the file has been moved or deleted after the user changes their password
Bug: https://pms.uniontech.com/bug-view-261605.html
  • Loading branch information
liyigang1 authored and Johnson-zs committed Jul 11, 2024
1 parent 6000a1d commit 448a8ee
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions include/dfm-io/dfm-io/error/en.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ enum DFMIOErrorCode {
DFM_IO_ERROR_OPEN_FLAG_ERROR, // File open flag is error
DFM_IO_ERROR_INFO_NO_ATTRIBUTE, // File info has no attribute
DFM_IO_ERROR_FTS_OPEN, // open file by fts failed
DFM_IO_ERROR_HOST_IS_DOWN, // remote server maybe down
};

inline const QString GetError_En(DFMIOErrorCode errorCode)
Expand Down Expand Up @@ -179,6 +180,8 @@ inline const QString GetError_En(DFMIOErrorCode errorCode)
return QObject::tr("open file by fts failed");
case DFM_IO_ERROR_USER_FAILED:
return QString();
case DFM_IO_ERROR_HOST_IS_DOWN:
return QObject::tr("Host is down");
}

return QString("Unknown error");
Expand Down
8 changes: 8 additions & 0 deletions src/dfm-io/dfm-io/dfileinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,14 @@ void DFileInfoPrivate::setErrorFromGError(GError *gerror)
{
if (!gerror)
return;

if (g_error_matches(gerror, G_IO_ERROR,G_IO_ERROR_FAILED) &&
QString(gerror->message).contains(strerror(EHOSTDOWN))) {
error.setCode(DFMIOErrorCode::DFM_IO_ERROR_HOST_IS_DOWN);
error.setMessage(gerror->message);
return;
}

error.setCode(DFMIOErrorCode(gerror->code));
if (error.code() == DFMIOErrorCode::DFM_IO_ERROR_FAILED)
error.setMessage(gerror->message);
Expand Down

0 comments on commit 448a8ee

Please sign in to comment.