Skip to content

Commit

Permalink
Merge branch 'main' into far3-dev-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
michaellukashov committed Feb 24, 2024
2 parents 6c1217c + c9f195b commit a9eb6bd
Show file tree
Hide file tree
Showing 97 changed files with 1,606 additions and 1,466 deletions.
9 changes: 4 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ jobs:
name: FarNetBox.${{ matrix.platform }}
path: ./*.7z
overwrite: true
retention-days: 30
retention-days: 2

create-release:
needs: [build]
Expand All @@ -103,18 +103,17 @@ jobs:
- name: Download archives
uses: actions/download-artifact@v4
with:
# name: FarNetBox.${{ matrix.platform }}
pattern: FarNetBox.*
path: FarNetBox
path: FarNetBox/
merge-multiple: true

- name: Display structure of downloaded files
run: ls -R FarNetBox
run: ls -R FarNetBox/

- name: Create release
shell: bash
run: |
gh release create v${{ env.version_short }} --draft --title "NetBox ${{ env.version_short }}" FarNetBox/*
gh release create v${{ env.version_short }} --draft --generate-notes --title "NetBox ${{ env.version_short }}" FarNetBox/*.7z
env:
# GITHUB_TOKEN: ${{ secrets.NETBOX_GITHUB_TOKEN }}
GH_TOKEN: ${{ github.token }}
25 changes: 18 additions & 7 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,24 @@
## [Unreleased] - ReleaseDate


## [24.2.2.594] - 2024-02-24

### Fixes

- gh-411 Fix list sorting


## [24.2.2.593] - 2024-02-24

### Changes

- Upgrade WinSCP sources: WinSCP 6.3.1

### Fixes

- Correction of: gh-409 Debug log loses messages


## [24.2.2.591] - 2024-02-23

### Fixes
Expand Down Expand Up @@ -58,7 +76,6 @@ https://forum.farmanager.com/viewtopic.php?p=177178#p177178 p.2

## [24.2.1.580] - 2024-02-04


### Changes

- Upgrade dependencies: zlib-ng 2.1.6
Expand All @@ -73,7 +90,6 @@ Thanks to ssvine https://github.com/ssvine

## [24.2.0.578] - 2024-02-02


### Fixes

Thanks to ssvine https://github.com/ssvine
Expand All @@ -95,7 +111,6 @@ https://forum.farmanager.com/viewtopic.php?p=177022#p177022

## [24.1.1.575] - 2024-01-23


### Fixes

- Bugfix: Crash when session option "[x] Cache visited remote directories" is set
Expand All @@ -113,7 +128,6 @@ https://forum.farmanager.com/viewtopic.php?p=176925#p176925 p.3

## [24.1.1.570] - 2024-01-07


### Fixes

- Transfer on background: fix found issues
Expand All @@ -127,7 +141,6 @@ https://forum.farmanager.com/viewtopic.php?p=176900#p176900

## [24.1.0.566-RC7] - 2024-01-02


### Fixes

- Fix transfer on background issues
Expand All @@ -136,15 +149,13 @@ https://forum.farmanager.com/viewtopic.php?p=176900#p176900

## [23.12.1.564-RC6] - 2023-12-30


### Fixes

- S3: Fix Upload/Download large files


## [23.12.1.561-RC5] - 2023-12-27


### Fixes

- Fix connect from History
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Far-NetBox: SFTP/FTP/SCP/WebDAV/S3 client for Far Manager 3.0 x86/x64/ARM64
| Appveyor | [![Build status](https://ci.appveyor.com/api/projects/status/91lhdjygkenumcmv?svg=true)](https://ci.appveyor.com/project/michaellukashov/far-netbox) |


Based on [WinSCP](http://winscp.net/eng/index.php) version 6.3.0 Copyright (c) 2000-2024 Martin Prikryl
Based on [WinSCP](http://winscp.net/eng/index.php) version 6.3.1 Copyright (c) 2000-2024 Martin Prikryl

Based on [WinSCP as FAR Plugin: SFTP/FTP/SCP client for FAR version 1.6.2](http://winscp.net/download/winscpfar162setup.exe) Copyright (c) 2000-2009 Martin Prikryl

Expand Down
14 changes: 7 additions & 7 deletions libs/tinylog/src/Buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,30 +26,31 @@ Buffer::~Buffer()
* -1 : fail, buffer full
*/
int32_t Buffer::TryAppend(struct tm * pt_time, int64_t u_sec, const char * file_name, int32_t line,
const char * func_name, std::string & str_log_level, const char * log_data)
const char * func_name, const char* str_log_level, const char * log_data, int64_t to_write)
{
/*
* date: 11 byte
* time: 13 byte
* line number: at most 5 byte
* log level: 9 byte
*/
const std::string::size_type append_len = 24 + (file_name ? strlen(file_name) : 0) + 5 +
(func_name ? strlen(func_name) : 0) + 9 + strlen(log_data);
const size_t prefix_len = 24 + (file_name ? strlen(file_name) : 0) + 5 +
(func_name ? strlen(func_name) : 0) + 9;
const size_t append_len = prefix_len + to_write; // strlen(log_data);

if (append_len + size_ > capacity_)
if (append_len + size_ >= capacity_)
{
return -1;
}

int n_append = 0;
if (file_name && *file_name && line > 0 && func_name && *func_name && !str_log_level.empty())
if (file_name && *file_name && line > 0 && func_name && *func_name && !(strlen(str_log_level) == 0))
{
n_append = sprintf_s(data_ + size_, capacity_ - size_,
"%d-%02d-%02d %02d:%02d:%02d.%.03d %10s:%3d %16s %10s %s\n",
pt_time->tm_year + 1900, pt_time->tm_mon + 1, pt_time->tm_mday,
pt_time->tm_hour, pt_time->tm_min, pt_time->tm_sec, static_cast<int>(u_sec / 1000),
file_name ? file_name : "", line, func_name ? func_name : "", str_log_level.c_str(),
file_name ? file_name : "", line, func_name ? func_name : "", str_log_level,
log_data);
}
else
Expand Down Expand Up @@ -82,7 +83,6 @@ int32_t Buffer::TryAppend(const void * pt_log, int32_t ToWrite)
{
return -1;
}
// TODO: libmemcpy_memmove
memmove(data_ + size_, pt_log, ToWrite);
const int32_t n_append = ToWrite;
if (n_append > 0)
Expand Down
25 changes: 18 additions & 7 deletions libs/tinylog/src/LogStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <tinylog/LogStream.h>
#include <tinylog/Config.h>
//#include <tinylog/LockFreeQueue.h>
// #include <Sysutils.hpp>
// #include <Sysutils.hpp> // for DEBUG_PRINTF


namespace tinylog {
Expand Down Expand Up @@ -95,19 +95,29 @@ void LogStream::SetFile(FILE * file)
file_ = file;
}

int64_t LogStream::InternalWrite(const char * log_data, int64_t ToWrite)
int64_t LogStream::InternalWrite(const char * log_data, int64_t to_write)
{
const int64_t Result = ToWrite;
const int64_t Result = to_write;
UpdateBaseTime();
// queue_->Push(log);
char * data_to_write = (char * )log_data;

pthread_mutex_lock(&mutex_);

// DEBUG_PRINTF("ToWrite: %d", (int)to_write);
while (true)
{
auto & buff = drain_buffer_ ? back_buff_ : front_buff_;
// append to the current buffer
if (buff->TryAppend(&tm_base_, static_cast<int64_t>(tv_base_.tv_usec), file_name_, line_, func_name_, str_log_level_, log_data) < 0)
int64_t need_capacity = static_cast<int64_t>(buff->Capacity() - buff->Size());
if (to_write > need_capacity)
{
// trunc log_data
tmp_buff_ = std::make_unique<Buffer>(need_capacity);
tmp_buff_->TryAppend(log_data, need_capacity);
data_to_write = tmp_buff_->Data();
to_write = need_capacity;
}
if (buff->TryAppend(&tm_base_, static_cast<int64_t>(tv_base_.tv_usec), file_name_, line_, func_name_, str_log_level_, data_to_write, to_write) < 0)
{
if (drain_buffer_)
{
Expand All @@ -116,9 +126,10 @@ int64_t LogStream::InternalWrite(const char * log_data, int64_t ToWrite)
pthread_mutex_unlock(&mutex_);
while (drain_buffer_)
{
// yield execution to another thread
// usially it will require only one iteration
// yield execution to another thread
// usually it will require only one iteration
Sleep(1);
// DEBUG_PRINTF("after Sleep");
}
pthread_mutex_lock(&mutex_);
}
Expand Down
7 changes: 4 additions & 3 deletions libs/tinylog/tinylog/Buffer.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

//#include <stdio.h>
#include <string>
// #include <stdio.h>
// #include <string>

#include "Utils.h"

Expand All @@ -16,12 +16,13 @@ class Buffer
~Buffer();

int32_t TryAppend(struct tm* pt_time, int64_t u_sec, const char* file_name, int32_t line,
const char* func_name, std::string& str_log_level, const char* log_data);
const char* func_name, const char* str_log_level, const char* log_data, int64_t to_write);
int32_t TryAppend(const void* pt_log, int32_t ToWrite);

void Clear();
uint64_t Size() const;
uint64_t Capacity() const;
char * Data() const { return data_; }
int32_t Flush(FILE* file);

private:
Expand Down
2 changes: 1 addition & 1 deletion libs/tinylog/tinylog/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
#include <cstdint>

constexpr int32_t TIME_OUT_SECOND = 3;
constexpr size_t LOG_BUFFER_SIZE = 4 * 1024;
constexpr size_t LOG_BUFFER_SIZE = 16 * 1024;
constexpr const char LOG_PATH[] = "./test.log";
3 changes: 2 additions & 1 deletion libs/tinylog/tinylog/LogStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,13 @@ class LogStream

std::unique_ptr<Buffer> front_buff_;
std::unique_ptr<Buffer> back_buff_;
std::unique_ptr<Buffer> tmp_buff_;
// std::unique_ptr<LockFreeQueue> queue_;
FILE * file_{nullptr}; // TODO: use gsl::not_null
const char * file_name_{nullptr}; // TODO: use gsl::not_null
int32_t line_{0};
const char * func_name_{nullptr};
std::string str_log_level_;
const char * str_log_level_;
timeval tv_base_{};
struct tm tm_base_{};
pthread_mutex_t & mutex_;
Expand Down
5 changes: 5 additions & 0 deletions libs/tinylog/tinylog/platform_win32.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ static int pthread_mutex_unlock(pthread_mutex_t *mtx)
return 0;
}

static bool pthread_mutex_tryenter(pthread_mutex_t *mtx)
{
return TryEnterCriticalSection(mtx) != FALSE;
}

typedef struct pthread_cond_t_
{
HANDLE event_;
Expand Down
36 changes: 22 additions & 14 deletions src/NetBox/FarDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,24 @@ inline TRect Rect(int32_t Left, int32_t Top, int32_t Right, int32_t Bottom)
return TRect(Left, Top, Right, Bottom);
}

const TObjectClassId OBJECT_CLASS_TDialogIdleThread = static_cast<TObjectClassId>(nb::counter_id());
class TFarDialogIdleThread : public TSimpleThread
constexpr const TObjectClassId OBJECT_CLASS_TDialogIdleThread = static_cast<TObjectClassId>(nb::counter_id());
class TFarDialogIdleThread final : public TSimpleThread
{
TFarDialogIdleThread() = delete;
public:
TFarDialogIdleThread() = delete;
explicit TFarDialogIdleThread(gsl::not_null<TFarDialog *> Dialog, DWORD Millisecs) noexcept :
TSimpleThread(OBJECT_CLASS_TDialogIdleThread),
FDialog(Dialog),
FMillisecs(Millisecs)
{}

virtual ~TFarDialogIdleThread() noexcept override
virtual ~TFarDialogIdleThread() noexcept override = default;

void InitIdleThread()
{
WaitFor(400);
SAFE_CLOSE_HANDLE(FEvent);
TFarDialogIdleThread::Terminate();
TSimpleThread::InitSimpleThread("NetBox Dialog Idle Thread");
FEvent = ::CreateEvent(nullptr, FALSE, FALSE, nullptr);
Start();
}

virtual void Execute() override
Expand All @@ -50,18 +52,24 @@ class TFarDialogIdleThread : public TSimpleThread
virtual void Terminate() override
{
FFinished = true;
if (FEvent)
::SetEvent(FEvent);
TriggerEvent();
}

void InitIdleThread()
virtual void Close() override
{
TSimpleThread::InitSimpleThread("NetBox Dialog Idle Thread");
FEvent = ::CreateEvent(nullptr, FALSE, FALSE, nullptr);
Start();
TSimpleThread::Close();
SAFE_CLOSE_HANDLE(FEvent);
}

private:
void TriggerEvent()
{
if (CheckHandle(FEvent))
{
::SetEvent(FEvent);
}
}

gsl::not_null<TFarDialog *> FDialog;
DWORD FMillisecs{0};
HANDLE FEvent{INVALID_HANDLE_VALUE};
Expand All @@ -75,7 +83,7 @@ TFarDialog::TFarDialog(gsl::not_null<TCustomFarPlugin *> AFarPlugin) noexcept :

TFarDialog::~TFarDialog() noexcept
{
FTIdleThread->Terminate();
FTIdleThread->Close();
for (int32_t Index = 0; Index < GetItemCount(); ++Index)
{
TFarDialogItem * Item = GetItem(Index);
Expand Down
8 changes: 4 additions & 4 deletions src/NetBox/FarDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class TFarDialog : public TObject
int32_t GetResult() const { return FResult; }
TPoint GetMaxSize() const;

const TFarKeyEvent & GetOnKey() const { return FOnKey; }
TFarKeyEvent & GetOnKey() { return FOnKey; }
void SetOnKey(TFarKeyEvent && Value) { FOnKey = std::move(Value); }

void Redraw();
Expand Down Expand Up @@ -398,7 +398,7 @@ class TFarButton : public TFarDialogItem
void SetBrackets(TFarButtonBrackets Value);
virtual bool GetCenterGroup() const override { return TFarDialogItem::GetCenterGroup(); }
virtual void SetCenterGroup(bool Value) override { TFarDialogItem::SetCenterGroup(Value); }
virtual const TFarButtonClickEvent & GetOnClick() const { return FOnClick; }
virtual const TFarButtonClickEvent & GetOnClick() { return FOnClick; }
virtual void SetOnClick(TFarButtonClickEvent && Value) { FOnClick = std::move(Value); }

protected:
Expand Down Expand Up @@ -428,7 +428,7 @@ class TFarCheckBox : public TFarDialogItem
virtual void SetCaption(const UnicodeString & Value) { SetData(Value); }
bool GetAllowGrayed() const { return GetFlag(DIF_3STATE); }
void SetAllowGrayed(bool Value) { SetFlag(DIF_3STATE, Value); }
virtual const TFarAllowChangeEvent & GetOnAllowChange() const { return FOnAllowChange; }
virtual TFarAllowChangeEvent & GetOnAllowChange() { return FOnAllowChange; }
virtual void SetOnAllowChange(TFarAllowChangeEvent && Value) { FOnAllowChange = std::move(Value); }
virtual bool GetChecked() const override { return TFarDialogItem::GetChecked(); }
virtual void SetChecked(bool Value) override { TFarDialogItem::SetChecked(Value); }
Expand All @@ -451,7 +451,7 @@ class TFarRadioButton : public TFarDialogItem
virtual void SetChecked(bool Value) override { TFarDialogItem::SetChecked(Value); }
virtual UnicodeString GetCaption() const { return GetData(); }
virtual void SetCaption(const UnicodeString & Value) { SetData(Value); }
virtual const TFarAllowChangeEvent & GetOnAllowChange() const { return FOnAllowChange; }
virtual TFarAllowChangeEvent & GetOnAllowChange() { return FOnAllowChange; }
virtual void SetOnAllowChange(TFarAllowChangeEvent && Value) { FOnAllowChange = std::move(Value); }

protected:
Expand Down
Loading

0 comments on commit a9eb6bd

Please sign in to comment.