0
Under review

Textastic breaks symbolic links

Jeremy Sonander 6 months ago updated 6 months ago 10

I just narrowly avoided messing up our web server by using Textastic to edit its pages. 

The issue is when you edit a symbolic link as you save, rather than writing changes back to the link, it deletes the link, creates a new file where the link was and saves to that. 

For example, I have 

a.html

and lets say I want another page with the same content and dont want the hassle of maintaining both, so I create a link to it using a command like this

ln -s a.html b.html


With other editors I can edit either a.html or b.html and both update. With Textastic when I edit b.html and save, only b.html is changed. The link I created to a is broken leaving a.html with the old content. 

Under review

Hello,

thanks for letting me know about this issue.

It should work if you download, edit and upload the file that the symbolic link links to.

Textastic should probably at least warn you when you are trying to upload to a symbolic link.

Can you please tell me which other editors handle this properly?

Hmm, I just noticed that this is in the "Textastic for Mac" forum which doesn't have an SFTP client.

Are you having this issue on a Mac or on iOS? Is this when opening a local symbolic link on Mac?

Its on a Mac and I am editing files via a LAN connection to the web server. It's a samba share exported by the web server running Linux, Ubuntu 18.04.5 LTS to be specific. 


I notice the situation is handled fine by Textastic if the files are on a local drive. There it does preserve the links. 
It appears Textastic handles the process of saving differently if the target is on a network share. 

Hmm, interesting, does Samba/SMB even support symbolic links (since it is a Windows protocol)?

What happens when you try to edit the same file using Apple's TextEdit? It uses the same NSDocument architecture provided by Apple's Cocoa framework that is also used by Textastic.

Apples Text Edit and Xcode, as well as Sublime Text preserve the links. Textastic is the first thing I have seen that recreates the file from scratch. It never occurred to me that this might happen and was something I needed to check for. 


I only spotted the problem because I noticed git reporting a file type change when I did the check in. I wasn't expecting to see that and fortunately stopped to investigate. 

Correction. 
It turns out Text Edit and Xcode break the link for files on a samba share, but preserve it and write to the linked file when the files are local. 

Only Sublime Text behaves consistently and retains the link when saving both local and network files. 

Ok, then it looks like this is actually a bug in Apple's Cocoa framework since both TextEdit and Xcode use NSDocument which should handle file saving and symbolic links correctly. 

I'll still try to reproduce the issue and report it to Apple. 

Ok, I'll try to reproduce the problem. I'm glad you catched the issue before it caused damage. 

Could you please send me a copy of the smb.conf file (or just the relevant parts of it) so I'm using the same settings?

+1

Its a fairly vanilla samba file, below is all thats left after I removed the comments.

That surprised me because I had tuned it for the Mac. Probably those settings got lost in some Ubuntu update, so this is proving to be a useful session. 

I will reapply the advice here 

https://wiki.samba.org/index.php/Configure_Samba_to_Work_Better_with_Mac_OS_X

and report back on if it is still misbehaving after Samba is optimised for Mac clients. 

[global]

log file = /var/log/samba/log.%m
max log size = 1000
syslog = 0
panic action = /usr/share/samba/panic-action %d
server role = standalone server
obey pam restrictions = yes
unix password sync = yes
passwd program = /usr/bin/passwd %u
passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .

pam password change = yes
map to guest = bad user
ntlm auth = yes


[Data]
comment = "Cube Data Area"
path = /home/data
public = no
writable = yes
printable = no
browsable = yes
# needed for osx access
posix locking = no
valid users=jeremy julia

[homes]
browsable = yes
writeable = yes


[WebSpace]
comment = "Cube Web Server Files"
path = /var/www
public = no
writable = yes
printable = no
browsable = yes
# needed for osx access
posix locking = no
valid users=jeremy julia adrian clari

Tried the apple optimisation recommendations from

https://wiki.samba.org/index.php/Configure_Samba_to_Work_Better_with_Mac_OS_X

and it makes no difference. Symbolic links still replaced with regular files both using Sublime Text and Text Edit. 


So people need to tread with care on any system using symbolic links and these editors.