Go Back   Cockos Incorporated Forums > REAPER Forums > REAPER for Linux

Reply
 
Thread Tools
Old 10-02-2023, 02:30 PM   #1
brunetton
Human being with feelings
 
Join Date: Nov 2021
Location: France
Posts: 21
Default Can't use symlinks for ini configuration files, reaper rewrites them as regular files

Hi

I'm a (registered) user of Reaper for years now and yesterday I don't know exactly how and why, I lost the Reaper configuration folder 😲 So I started from scratch; I'm rebuilding my keymap, this is probably the longer to find my config back.

Anyway this time I decided to do things the right way: storing config files elsewhere in a Git repo with all my other config files (a LOT) and use a symlink from Reaper config dir.

But after doing this, I noticed that Reaper erase my reaper.ini symlink with a regular file. It would be nice if Reaper could follow the link and write inside the linked file (in my sync Git repo elsewhere).

## Steps to reproduce:

1. Create symlink to reaper.ini

Code:
cd ~/.config/REAPER/
mv reaper.ini ~/git/my_dotfiles/
ln -s ~/git/my_dotfiles/reaper.ini .
2. Change something in configuration from Reaper, and constat that ~/.config/REAPER/reaper.ini is not a symlink anymore but a regular file


=> surprisingly this works well for reaper-kb.ini and reaper-fxfolders.ini files (and probably others ?)


Thanks !

PS: as always, I must say that it's a pain in the ass using this forum. PLEASE migrate to Discourse !

Last edited by brunetton; 10-02-2023 at 03:17 PM.
brunetton is offline   Reply With Quote
Old 10-03-2023, 06:34 AM   #2
/AND/
Human being with feelings
 
Join Date: Aug 2022
Posts: 861
Default

Weird. When I installed Flatpak Reaper side-by-side the 'regular' one, decided to combine their config dir by simply deleting Flatpak's and making a symlink to the regular one instead. Works perfectly, actually - no rewrites or issues (except the expected Flatpak issues with VSTs etc.).

Just sharing my experience irt Reaper and symlinks. It's probably something Justin needs to have a peek at.
/AND/ is offline   Reply With Quote
Old 10-03-2023, 09:30 AM   #3
biopsin
Human being with feelings
 
Join Date: Sep 2010
Location: oslo
Posts: 143
Default

Ÿou could also append an attribute to the file
__________________
Voidlinux_glibc / gcc_12.2. / libSwell_GDK2 - 250423 /
Reaper_6.82 / NI_KA2 / Dynaudio_BM6
biopsin is offline   Reply With Quote
Old 11-03-2023, 12:20 PM   #4
Fabian
Human being with feelings
 
Fabian's Avatar
 
Join Date: Sep 2008
Location: Sweden
Posts: 7,628
Default

I just now created symlinks from the Effects folder to some JSFX that I keep in a git repo on another drive, and this seems to work.

The only thing is that when editing the file outside of Reaper, and Reaper has the IDE open, it does not seem to recognize that the fiel was edited. For non-symlinks, Reaper asks if I want to re-open the changed file, but this does not happen now. I have to close the IDE and open it again for the change to register in Reaper.
__________________
// MVHMF
I never always did the right thing, but all I did wasn't wrong...
Fabian is offline   Reply With Quote
Old 11-03-2023, 05:52 PM   #5
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 16,809
Default

the reason for this is we write out a new ini next to the existing, then rename it over.. I suppose we could follow the symlink first then do it on the underlying file...

Edit: we'll do this. If you want to test, grab the latest WDL from github.com/justinfrankel/WDL, and use this patch:

Code:
commit de516cc0e42180580d4e8ecf5e8781ee34ae7d26
Author: Justin Frankel <justin+carb@cockos.com>
Date:   Fri Nov 3 21:17:23 2023 -0400

    + Linux: improve support for ini files which are symlinks [t=283160]
    
    swell-ini: improve support for symlinked ini files

diff --git a/WDL/swell/swell-ini.cpp b/WDL/swell/swell-ini.cpp
index d3a0463..fd073c3 100644
--- a/WDL/swell/swell-ini.cpp
+++ b/WDL/swell/swell-ini.cpp
@@ -71,6 +71,19 @@ static time_t getfileupdtimesize(const char *fn, int *szOut)
   struct stat st;
   *szOut = 0;
   if (!fn || !fn[0] || stat(fn,&st)) return 0;
+
+  if (S_ISLNK(st.st_mode))
+  {
+    char *linkpath = realpath(fn,NULL);
+    if (linkpath)
+    {
+      const bool ok = !stat(linkpath,&st);
+      free(linkpath);
+
+      if (!ok) return 0;
+    }
+  }
+
   *szOut = (int)st.st_size;
   return st.st_mtime;
 }
@@ -238,7 +251,18 @@ static void WriteBackFile(iniFileContext *ctx)
 {
   if (!ctx||!ctx->m_curfn) return;
   char newfn[1024];
-  lstrcpyn_safe(newfn,ctx->m_curfn,sizeof(newfn)-8);
+
+  const char *curfn = ctx->m_curfn;
+
+  struct stat st;
+  char *needfree = NULL;
+  if (!stat(curfn,&st) && S_ISLNK(st.st_mode))
+  {
+    needfree = realpath(curfn,NULL);
+    if (needfree) curfn = needfree;
+  }
+
+  lstrcpyn_safe(newfn,curfn,sizeof(newfn)-8);
   {
     char *p=newfn;
     while (*p) p++;
@@ -255,7 +279,11 @@ static void WriteBackFile(iniFileContext *ctx)
   }
 
   FILE *fp = WDL_fopenA(newfn,"w");
-  if (!fp) return;
+  if (!fp)
+  {
+    free(needfree);
+    return;
+  }
   
   flock(fileno(fp),LOCK_EX);
   
@@ -282,14 +310,15 @@ static void WriteBackFile(iniFileContext *ctx)
   flock(fileno(fp),LOCK_UN);
   fclose(fp);
 
-  if (!rename(newfn,ctx->m_curfn))
+  if (!rename(newfn,curfn))
   {
-    ctx->m_curfn_time = getfileupdtimesize(ctx->m_curfn,&ctx->m_curfn_sz);
+    ctx->m_curfn_time = getfileupdtimesize(curfn,&ctx->m_curfn_sz);
   }
   else
   {
     // error updating, hmm how to handle this?
   }
+  free(needfree);
 }
 
 BOOL WritePrivateProfileSection(const char *appname, const char *strings, const char *fn)

Last edited by Justin; 11-03-2023 at 06:18 PM.
Justin is offline   Reply With Quote
Old 02-02-2024, 11:00 AM   #6
brunetton
Human being with feelings
 
Join Date: Nov 2021
Location: France
Posts: 21
Default

Quote:
Originally Posted by Justin View Post
the reason for this is we write out a new ini next to the existing, then rename it over.. I suppose we could follow the symlink first then do it on the underlying file...

Edit: we'll do this.
[/code]
Thank you ! This is changing my life today. I lost all my Reaper config after updating to last version (probably because of this symlink situation) and I've created a Git repo to store my custom configuration (especially custom keyboard shortcuts, the graal).
This is working very well and I'm super happy with it 💓

For anyone interested, here is my .gitignore file content:

Code:
Scripts/Cockos
Effects
Data
Cusrors
reaper-install-rev.txt
ReaPack/cache
UserPlugins/reaper_reapack-x86_64.so
reaper-fxtags.ini
reaper-jsfx.ini
reaper-recentfx.ini
reaper-vstplugins64.ini
reaper-fxtags.ini
reaper-clap-linux-x86_64.ini
presets
MetadataCaches
ColorThemes
Some things are probably missing but this is good start.
brunetton is offline   Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 08:23 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.