Browse Source

Avoid the Win32 MF_REMOVE macro in the file protocol

master
evgeny 1 week ago
parent
commit
fe03feaf4a
  1. 3
      src/member_files/protocol.h
  2. 6
      src/member_files/storage.c

3
src/member_files/protocol.h

@ -30,8 +30,9 @@ int mf_avatar_file_valid(const char* file);
#define MF_FILE 1 #define MF_FILE 1
#define MF_DIRECTORY 2 #define MF_DIRECTORY 2
/* MF_REMOVE — системный макрос Win32; для удаления файла/каталога используем отдельное имя. */
enum mf_command { enum mf_command {
MF_LIST = 1, MF_STAT, MF_READ, MF_BEGIN_WRITE, MF_WRITE, MF_COMMIT, MF_ABORT, MF_MKDIR, MF_RENAME, MF_REMOVE, MF_LIST = 1, MF_STAT, MF_READ, MF_BEGIN_WRITE, MF_WRITE, MF_COMMIT, MF_ABORT, MF_MKDIR, MF_RENAME, MF_REMOVE_PATH,
MF_STREAM_WRITE, MF_STREAM_READ, MF_STREAM_DATA, MF_STREAM_END, MF_STREAM_CANCEL, MF_QUOTA MF_STREAM_WRITE, MF_STREAM_READ, MF_STREAM_DATA, MF_STREAM_END, MF_STREAM_CANCEL, MF_QUOTA
}; };
enum mf_status { enum mf_status {

6
src/member_files/storage.c

@ -494,7 +494,7 @@ static int store_command(struct mf_storage* s, uint64_t group, uint64_t peer, co
if (rc) return rc; if (rc) return rc;
uint8_t version[16]; store_version(s, &info, version); uint8_t version[16]; store_version(s, &info, version);
if ((!mf_zero(q->version, 16) && memcmp(q->version, version, 16)) || if ((!mf_zero(q->version, 16) && memcmp(q->version, version, 16)) ||
((q->command == MF_READ || q->command == MF_RENAME || q->command == MF_REMOVE || q->cursor) && mf_zero(q->version, 16))) ((q->command == MF_READ || q->command == MF_RENAME || q->command == MF_REMOVE_PATH || q->cursor) && mf_zero(q->version, 16)))
return MF_STALE; return MF_STALE;
r->size = info.size; r->mtime = info.mtime; r->type = info.type; memcpy(r->version, version, 16); r->size = info.size; r->mtime = info.mtime; r->type = info.type; memcpy(r->version, version, 16);
if (q->command == MF_STAT) return MF_OK; if (q->command == MF_STAT) return MF_OK;
@ -527,7 +527,7 @@ static int store_command(struct mf_storage* s, uint64_t group, uint64_t peer, co
if (u->active && !strncmp(u->path, path, n) && (!u->path[n] || u->path[n] == '/')) return MF_BUSY; if (u->active && !strncmp(u->path, path, n) && (!u->path[n] || u->path[n] == '/')) return MF_BUSY;
} }
store_invalidate(s); store_invalidate(s);
if (q->command == MF_REMOVE) { if (q->command == MF_REMOVE_PATH) {
struct store_user* user = store_user_get(s, q->owner, 1); struct store_user* user = store_user_get(s, q->owner, 1);
if (!user) return MF_IO_ERROR; if (!user) return MF_IO_ERROR;
rc = mf_disk_remove(&s->root, path, info.type == MF_DIRECTORY); rc = mf_disk_remove(&s->root, path, info.type == MF_DIRECTORY);
@ -580,7 +580,7 @@ void mf_storage_execute(struct mf_storage* s, uint64_t group, uint64_t peer, con
(unsigned long long)q->request_id, mf_command_text(q->command), q->path, (unsigned long long)q->offset, (unsigned long long)q->request_id, mf_command_text(q->command), q->path, (unsigned long long)q->offset,
(unsigned long long)q->size, (unsigned long long)(user ? user->used : 0), (unsigned long long)q->size, (unsigned long long)(user ? user->used : 0),
(unsigned long long)(user ? user->reserved : 0), (unsigned long long)s->quota); (unsigned long long)(user ? user->reserved : 0), (unsigned long long)s->quota);
int mutates = q->command == MF_COMMIT || q->command == MF_MKDIR || q->command == MF_RENAME || q->command == MF_REMOVE; int mutates = q->command == MF_COMMIT || q->command == MF_MKDIR || q->command == MF_RENAME || q->command == MF_REMOVE_PATH;
struct store_receipt* slot = NULL; struct store_receipt* slot = NULL;
uint8_t wire[MF_WIRE_MAX], fingerprint[32]; uint8_t wire[MF_WIRE_MAX], fingerprint[32];
int n = mf_encode(q, wire, sizeof(wire)); int n = mf_encode(q, wire, sizeof(wire));

Loading…
Cancel
Save