3

It's my first time developing a project with other developers (only two, right now). Our idea is to edit the files right from the server, using a FTP/SFTP software such as FileZilla. We want that any file opened for editing become blocked, so the other user cannot edit it at the same time. Is this possible? If not with FileZilla, perhaps using other software? I've looked at Git, Codiad and other similar solutions, but they are too complicated (merge concurrent editions in GitHub is not trivial) or have bugs (Codiad is not saving the files). We thought that file-locking is primitive but good enough for us (we're in the same room). The question is: how do we implement it?

Rodrigo
  • 4,706
  • 6
  • 51
  • 94

4 Answers4

7

Don't go that way.
First of all, it's risky to have only one copy of your code and that's what will happen if you edit files on the server directly.
Secondly I really don't understand why people find git an overkill.
For small team and no actual delivery pipeline, you don't need to master the whole git powers. You don't even have to work with branches and merges.

All you need to start working with git is:
git clone URL_OF_REPOSITORY - to download a copy of repository and start working with it
git add PATH_TO_EDITED_FILE_OR_FOLDER - to mark files or/and folders as staged for commit
git commit -m 'DESCRIPTION OF CHANGES' - to commit/accept the changes in files and folders marked in previous step and save information about those changes locally
git push - to upload commited changes to the remote repository
git pull - to download changes committed and pushed by others from the remote repository

As you can see, the commands don't expect you to provide any sophisticated information. Just the url of remote repo, files you consider as ready to be shared with others and desired description of changes made. It's not hard, really. And one should really start being familiar with version control systems as this is one of the core skills in software development these days.

ElmoVanKielmo
  • 10,907
  • 2
  • 32
  • 46
  • 2
    This. I use git even in single developer projects. – MirMasej Aug 01 '16 at 12:40
  • Thanks. But to have the files in one place doesn't mean we have no daily backup. Second, other answer states "it only gets messsy if you both work on the same bit of code at the same time", that's exactly my concern. Don't want anything messy. Just want an old technology to work again. And yes, I know I need to learn Git (have worked a little with it), but I still think it's an overkill for our kind of work. – Rodrigo Aug 01 '16 at 22:58
  • @Rodrigo saying `the same bit of code` we mean really the same lines and not just the same file. Even if it happens, git will warn you and will put a nice diff in place of conflicting lines. All you have to do afterwards is to choose the right piece of code, remove the other and commit changes. What you will get by working via FTP on the remote file is simply overwriting the changes made by other developer without any warning. – ElmoVanKielmo Aug 02 '16 at 08:26
  • What I wanted is a simpler solution called file-locking. Still working on it, thanks. – Rodrigo Aug 04 '16 at 01:19
  • @Rodrigo apparently you are not aware how complex file locking over the network is. Shortly speaking the kernel can't identify the remote process obtaining a lock over the network. Some support was planned to be added in NFS version 4. I don't know what the status is - http://docstore.mik.ua/orelly/networking_2ndEd/nfs/ch11_02.htm Other than that mandatory file locking is disabled on Linux by default. One has to set flags while mounting partition and set additional file permissions http://stackoverflow.com/a/14234254/2431997 Only advisory lock is enabled by default. – ElmoVanKielmo Aug 04 '16 at 13:47
  • Sorry, but I always thought that the evolution of computers should not destroy old, useful features. Let me give a simple example: in the first versions of Paintbrush, one could move the cursor pixel by pixel using the keyboard arrows. When it became Paint, they removed that feature. Why? I've used file-locking over a network back in 1997 (in a Windows network), so I just don't get why everybody reacts as if "it can't be done, let's try a workaround?". Actually I'm getting sick of Ubuntu being made mostly of workarounds... – Rodrigo Aug 04 '16 at 18:16
  • @Rodrigo it still works on Windows. I wouldn't call using git a workaround - I never missed file locking over the network. I enjoy the possibility of working on the same (logically the same) file as my peer and getting changes merged automatically without a hassle. In fact it would be counterproductive if I change lines 800-1100 and I'm blocked by other developer working with lines 200-600. I accept the fact that you are not happy with the answer. I can only share what I know and my experience. Good luck anyway. – ElmoVanKielmo Aug 05 '16 at 06:57
  • I just thought that it would be faster the other way. But I'm not sure anymore. Anyway, thanks for the script, and sorry for not answering earlier. – Rodrigo Aug 05 '16 at 07:57
3

if u are owner of machine u can install Koding for team (max 4 for free) and use webide in collaborative mode.

carlo denaro
  • 425
  • 6
  • 14
  • 1
    Yeah, I can try that. Still, I'm amazed that a Server lack that kind of classic functionality! – Rodrigo Jul 25 '16 at 15:04
2
  • There's no file locking in FTP.
  • There's locking in SFTP, but it is not generally supported, see SFTP file lock mechanism for details.
  • There's locking in WebDAV, but afaik common implementations like mod_dav actually lock a file within a WebDAV "world" only, the actual underlying file is not locked in any way.

So I'm not aware of any generally available mechanism for locking files remotely.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
2

Beeing a small team loking is ok (it shouldnt be used on big projects) but you should look into git, I have found it only gets messsy if you both work on the same bit of code at the same time. To remove some of the complexity look into a Git GUI, the one I use is sourcetree but there are many others, they just help you visualise what you are doing and what changes are happening.

now to answering your question, I dont know of any standalone software that will do what you are after but dreamweaver did have a way of locking files for itself. This was done by creating a file called filename.lock, this was a text file with details of who locked it. You could do something like this manually, so when you want to lock a file you create the lock file, then to unlock it you delete it and you both promice to not edit files that have a lock file.

Its not the best solution or the neetest but depending on how you work, it could work.

Topher Brink
  • 329
  • 2
  • 13